selda 0.1.12 → 0.1.12.1
raw patch · 4 files changed
+18/−3 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Database.Selda.Backend: [ppColAttrsHook] :: PPConfig -> SqlTypeRep -> [ColAttr] -> ([ColAttr] -> Text) -> Text
+ Database.Selda.Backend: [ppTypeHook] :: PPConfig -> SqlTypeRep -> [ColAttr] -> (SqlTypeRep -> Text) -> Text
- Database.Selda.Backend: PPConfig :: (SqlTypeRep -> Text) -> (SqlTypeRep -> Text) -> (Int -> Text) -> ([ColAttr] -> Text) -> Text -> Maybe Int -> PPConfig
+ Database.Selda.Backend: PPConfig :: (SqlTypeRep -> Text) -> (SqlTypeRep -> [ColAttr] -> (SqlTypeRep -> Text) -> Text) -> (SqlTypeRep -> Text) -> (Int -> Text) -> ([ColAttr] -> Text) -> (SqlTypeRep -> [ColAttr] -> ([ColAttr] -> Text) -> Text) -> Text -> Maybe Int -> PPConfig
Files
- ChangeLog.md +5/−0
- selda.cabal +2/−2
- src/Database/Selda/SQL/Print/Config.hs +8/−0
- src/Database/Selda/Table/Compile.hs +3/−1
ChangeLog.md view
@@ -1,6 +1,11 @@ # Revision history for Selda +## 0.1.12.1 -- 2018-02-27++* New PPConfig hook for more flexibility when compiling types.++ ## 0.1.12 -- 2018-01-11 * Allow recursive and optional foreign keys.
selda.cabal view
@@ -1,5 +1,5 @@ name: selda-version: 0.1.12+version: 0.1.12.1 synopsis: Multi-backend, high-level EDSL for interacting with SQL databases. description: This package provides an EDSL for writing portable, type-safe, high-level database code. Its feature set includes querying and modifying databases,@@ -84,7 +84,7 @@ build-depends: base >=4.8 && <5 , bytestring >=0.10 && <0.11- , exceptions >=0.8 && <0.9+ , exceptions >=0.8 && <0.10 , hashable >=1.1 && <1.3 , mtl >=2.0 && <2.3 , text >=1.0 && <1.3
src/Database/Selda/SQL/Print/Config.hs view
@@ -15,6 +15,9 @@ -- please use the 'ppTypePK' record instead. ppType :: SqlTypeRep -> Text + -- | Hook that allows you to modify 'ppType' output.+ , ppTypeHook :: SqlTypeRep -> [ColAttr] -> (SqlTypeRep -> Text) -> Text+ -- | The SQL type name of the given type for primary keys uses. , ppTypePK :: SqlTypeRep -> Text @@ -24,6 +27,9 @@ -- | List of column attributes. , ppColAttrs :: [ColAttr] -> Text + -- | Hook that allows you to modify 'ppColAttrs' output.+ , ppColAttrsHook :: SqlTypeRep -> [ColAttr] -> ([ColAttr] -> Text) -> Text+ -- | The value used for the next value for an auto-incrementing column. -- For instance, @DEFAULT@ for PostgreSQL, and @NULL@ for SQLite. , ppAutoIncInsert :: Text@@ -45,9 +51,11 @@ defPPConfig :: PPConfig defPPConfig = PPConfig { ppType = defType+ , ppTypeHook = \ty _ _ -> defType ty , ppTypePK = defType , ppPlaceholder = T.cons '$' . T.pack . show , ppColAttrs = T.unwords . map defColAttr+ , ppColAttrsHook = \_ ats _ -> T.unwords $ map defColAttr ats , ppAutoIncInsert = "NULL" , ppMaxInsertParams = Nothing }
src/Database/Selda/Table/Compile.hs view
@@ -44,9 +44,11 @@ compileTableCol :: PPConfig -> ColInfo -> Text compileTableCol cfg ci = Text.unwords [ fromColName (colName ci)- , ppType' cfg cty <> " " <> ppColAttrs cfg (colAttrs ci)+ , typeHook <> " " <> colAttrsHook ] where+ typeHook = ppTypeHook cfg cty attrs (ppType' cfg)+ colAttrsHook = ppColAttrsHook cfg cty attrs (ppColAttrs cfg) cty = colType ci attrs = colAttrs ci ppType'