Skip to content

Commit

Permalink
feat: haskellize record/field names in schema init sub-command
Browse files Browse the repository at this point in the history
  • Loading branch information
vst committed May 24, 2024
1 parent 09cdeda commit e5bd93a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ library:
- autodocodec-yaml
- brick
- bytestring
- casing
- githash
- hashable
- hasql
Expand Down
12 changes: 8 additions & 4 deletions src/Postmap/Spec/FromSchema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ module Postmap.Spec.FromSchema where
import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy as BL
import qualified Data.List as List
import qualified Data.Text as T
import Postmap.Introspect (Column (..), ColumnName (..), ColumnReference (..), Table (..), TableName (..))
import Postmap.Spec.Types (Field (..), FieldName (..), FieldReference (..), Record (..), RecordName (..), Spec (..))
import qualified Text.Casing as Casing


fromSchemaJson :: BL.ByteString -> Either String Spec
Expand Down Expand Up @@ -70,12 +72,14 @@ fromColumn Column {..} =
}


mkFieldNameFromColumnName :: ColumnName -> FieldName
mkFieldNameFromColumnName = MkFieldName . unColumnName
mkRecordNameFromTableName :: TableName -> RecordName
mkRecordNameFromTableName =
MkRecordName . T.pack . Casing.pascal . T.unpack . unTableName


mkRecordNameFromTableName :: TableName -> RecordName
mkRecordNameFromTableName = MkRecordName . unTableName
mkFieldNameFromColumnName :: ColumnName -> FieldName
mkFieldNameFromColumnName =
MkFieldName . T.pack . Casing.camel . T.unpack . unColumnName


mkFieldReferenceFromColumnReference :: ColumnReference -> FieldReference
Expand Down

0 comments on commit e5bd93a

Please sign in to comment.