relational-query 0.8.2.3 → 0.8.3.0
raw patch · 5 files changed
+31/−12 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Database.Relational.Query.Component: NoQuotation :: IdentifierQuotation
+ Database.Relational.Query.Component: Quotation :: Char -> IdentifierQuotation
+ Database.Relational.Query.Component: data IdentifierQuotation
+ Database.Relational.Query.Component: instance GHC.Show.Show Database.Relational.Query.Component.IdentifierQuotation
Files
- ChangeLog.md +8/−0
- relational-query.cabal +1/−1
- src/Database/Relational/Query.hs +1/−1
- src/Database/Relational/Query/Component.hs +7/−2
- src/Database/Relational/Query/TH.hs +14/−8
ChangeLog.md view
@@ -1,5 +1,13 @@ <!-- -*- Markdown -*- --> +## 0.8.3.0++- Add configuration to quote SQL string of table names.++## 0.8.2.3++- Add tested-with meta-data.+ ## 0.8.2.2 - Update for GHC 8.
relational-query.cabal view
@@ -1,5 +1,5 @@ name: relational-query-version: 0.8.2.3+version: 0.8.3.0 synopsis: Typeful, Modular, Relational, algebraic query engine description: This package contiains typeful relation structure and relational-algebraic query building DSL which can
src/Database/Relational/Query.hs view
@@ -50,7 +50,7 @@ Primary, Unique, NotNull) import Database.Relational.Query.Context import Database.Relational.Query.Component- (NameConfig (..), SchemaNameMode (..), Config (..), defaultConfig, ProductUnitSupport (..), Order (..))+ (NameConfig (..), SchemaNameMode (..), Config (..), defaultConfig, ProductUnitSupport (..), IdentifierQuotation (..), Order (..)) import Database.Relational.Query.Sub (SubQuery, unitSQL, queryWidth) import Database.Relational.Query.Projection (Projection, list) import Database.Relational.Query.Projectable
src/Database/Relational/Query/Component.hs view
@@ -24,9 +24,10 @@ , schemaNameMode , normalizedTableName , verboseAsCompilerWarning- , nameConfig),+ , nameConfig+ , identifierQuotation), defaultConfig,- ProductUnitSupport (..), Duplication (..),+ ProductUnitSupport (..), Duplication (..), IdentifierQuotation (..), -- * Duplication attribute showsDuplication,@@ -118,6 +119,7 @@ , normalizedTableName :: !Bool , verboseAsCompilerWarning :: !Bool , nameConfig :: !NameConfig+ , identifierQuotation :: !IdentifierQuotation } deriving Show -- | Default configuration.@@ -131,11 +133,14 @@ , nameConfig = NameConfig { recordConfig = RecordTH.defaultNameConfig , relationVarName = const varCamelcaseName }+ , identifierQuotation = NoQuotation } -- | Unit of product is supported or not. data ProductUnitSupport = PUSupported | PUNotSupported deriving Show +-- | Configuration for quotation of identifiers of SQL.+data IdentifierQuotation = NoQuotation | Quotation Char deriving Show -- | Result record duplication attribute data Duplication = All | Distinct deriving Show
src/Database/Relational/Query/TH.hs view
@@ -86,8 +86,8 @@ import Database.Relational.Query (Table, Pi, id', Relation, ProductConstructor (..),- NameConfig (..), SchemaNameMode (..),- Config (normalizedTableName, schemaNameMode, nameConfig), defaultConfig,+ NameConfig (..), SchemaNameMode (..), IdentifierQuotation (..),+ Config (normalizedTableName, schemaNameMode, nameConfig, identifierQuotation), defaultConfig, relationalQuerySQL, Query, relationalQuery, KeyUpdate, Insert, derivedInsert, InsertQuery, derivedInsertQuery, HasConstraintKey(constraintKey), Primary, NotNull, primary, primaryUpdate)@@ -260,10 +260,10 @@ dDs <- defineTableDerivations tableVar' relVar' insVar' insQVar' recordType' return $ iDs ++ dDs -tableSQL :: Bool -> SchemaNameMode -> String -> String -> String-tableSQL normalize snm schema table = case snm of- SchemaQualified -> normalizeS ++ '.' : normalizeT- SchemaNotQualified -> normalizeT+tableSQL :: Bool -> SchemaNameMode -> IdentifierQuotation -> String -> String -> String+tableSQL normalize snm iq schema table = case snm of+ SchemaQualified -> (qt normalizeS) ++ '.' : (qt normalizeT)+ SchemaNotQualified -> (qt normalizeT) where normalizeS | normalize = map toUpper schema@@ -271,7 +271,13 @@ normalizeT | normalize = map toLower table | otherwise = table+ qt = quote iq +quote :: IdentifierQuotation -> String -> String+quote NoQuotation s = s+quote (Quotation q) s = q : (escape s) ++ q : []+ where escape = (>>= (\c -> if c == q then [q, q] else [c]))+ derivationVarNameDefault :: String -> VarName derivationVarNameDefault = (`varNameWithPrefix` "derivationFrom") @@ -333,8 +339,8 @@ (table `varNameWithPrefix` "insert") (table `varNameWithPrefix` "insertQuery") (recordType recConfig schema table)- (tableSQL (normalizedTableName config) (schemaNameMode config) schema table)- (map (fst . fst) columns)+ (tableSQL (normalizedTableName config) (schemaNameMode config) (identifierQuotation config) schema table)+ (map ((quote (identifierQuotation config)) . fst . fst) columns) colsDs <- defineColumnsDefault (recordTypeName recConfig schema table) columns return $ tableDs ++ colsDs