summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeiHibino <>2018-06-22 13:36:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-06-22 13:36:00 (GMT)
commitbd79b8f20df3b7584a06f28d867e1e0480aca7c5 (patch)
tree4025ec0fa91a65546f0f8713c1b683a6a5501ca7
parentc2da1369fca7cdb020519b2156a2ba2d02a64fb5 (diff)
version 0.6.0.4HEAD0.6.0.4master
-rw-r--r--persistable-record.cabal5
-rw-r--r--src/Database/Record/TH.hs20
2 files changed, 14 insertions, 11 deletions
diff --git a/persistable-record.cabal b/persistable-record.cabal
index 61e57e6..39df557 100644
--- a/persistable-record.cabal
+++ b/persistable-record.cabal
@@ -1,5 +1,5 @@
name: persistable-record
-version: 0.6.0.3
+version: 0.6.0.4
synopsis: Binding between SQL database values and haskell records.
description: This package contiains types to represent table constraints and
interfaces to bind between SQL database values and Haskell records.
@@ -12,7 +12,8 @@ copyright: Copyright (c) 2013-2017 Kei Hibino
category: Database
build-type: Simple
cabal-version: >=1.10
-tested-with: GHC == 8.2.1
+tested-with: GHC == 8.4.1, GHC == 8.4.2, GHC == 8.4.3
+ , GHC == 8.2.1, GHC == 8.2.2
, GHC == 8.0.1, GHC == 8.0.2
, GHC == 7.10.1, GHC == 7.10.2, GHC == 7.10.3
, GHC == 7.8.1, GHC == 7.8.2, GHC == 7.8.3, GHC == 7.8.4
diff --git a/src/Database/Record/TH.hs b/src/Database/Record/TH.hs
index 8b52400..e608682 100644
--- a/src/Database/Record/TH.hs
+++ b/src/Database/Record/TH.hs
@@ -51,7 +51,7 @@ import GHC.Generics (Generic)
import Data.Array (Array)
import Language.Haskell.TH.Name.CamelCase
(ConName(conName), VarName(varName),
- conCamelcaseName, varCamelcaseName, varNameWithPrefix,
+ conCamelcaseName, varCamelcaseName,
toTypeCon, toDataCon, )
import Language.Haskell.TH.Lib.Extra (integralE, simpleValD, reportWarning)
import Language.Haskell.TH.Compat.Data (dataD')
@@ -92,15 +92,17 @@ instance Show NameConfig where
show = const "<nameConfig>"
-- | Default implementation of 'NameConfig' type.
--- To change how the generated record type and its columns are named,
+-- To change how generated record types and their columns are named,
-- use record update syntax:
--
--- > defaultNameConfig
--- > { recordTypeName = \schema table -> varCamelcaseName $ schema ++ "_" ++ table
--- > ^ append the table name after the schema name. e.g. "schemaTable"
--- > , columnName = \table column -> varCamelcaseName $ table ++ "_" ++ column
--- > ^ append the column name after the table name. e.g. "tableColumn"
--- > }
+-- @
+-- defaultNameConfig
+-- { recordTypeName = \\schema table -> 'varCamelcaseName' $ schema ++ "_" ++ table
+-- -- ^ append the table name after the schema name. e.g. "SchemaTable"
+-- , columnName = \\table column -> 'varCamelcaseName' $ table ++ "_" ++ column
+-- -- ^ append the column name after the table name. e.g. "tableColumn"
+-- }
+-- @
defaultNameConfig :: NameConfig
defaultNameConfig =
NameConfig
@@ -118,7 +120,7 @@ recordTemplate config scm = (toTypeCon &&& toDataCon) . recordTypeName config sc
-- | Variable expression of record column offset array.
columnOffsetsVarNameDefault :: Name -- ^ Table type name
-> VarName -- ^ Result expression variable name
-columnOffsetsVarNameDefault = (`varNameWithPrefix` "columnOffsets") . nameBase
+columnOffsetsVarNameDefault = varCamelcaseName . ("column_offsets_" ++) . nameBase
-- | Template of 'HasColumnConstraint' instance.
defineHasColumnConstraintInstance :: TypeQ -- ^ Type which represent constraint type