@@ -7,6 +7,7 @@ import Prelude
7
7
8
8
import Data.Default
9
9
import Data.String
10
+ import Data.Text (pack , unpack )
10
11
import Database.PostgreSQL.Query.Entity.Class
11
12
import Database.PostgreSQL.Query.TH.Common
12
13
import Database.PostgreSQL.Query.Types ( FN (.. ) )
@@ -29,6 +30,7 @@ data EntityOptions = EntityOptions
29
30
, eoIdType :: Name -- ^ Base type for Id
30
31
} deriving (Generic )
31
32
33
+ #if !MIN_VERSION_inflections(0,3,0)
32
34
instance Default EntityOptions where
33
35
def = EntityOptions
34
36
{ eoTableName = toUnderscore
@@ -37,6 +39,21 @@ instance Default EntityOptions where
37
39
, ''FromField, ''ToField ]
38
40
, eoIdType = ''Integer
39
41
}
42
+ #else
43
+ instance Default EntityOptions where
44
+ def = EntityOptions
45
+ { eoTableName = toUnderscore'
46
+ , eoColumnNames = toUnderscore'
47
+ , eoDeriveClasses = [ ''Ord, ''Eq, ''Show
48
+ , ''FromField, ''ToField ]
49
+ , eoIdType = ''Integer
50
+ }
51
+
52
+ toUnderscore' :: String -> String
53
+ toUnderscore' s = case toUnderscore $ pack s of
54
+ Left er -> error $ " toUnderscore: " ++ show er
55
+ Right a -> unpack a
56
+ #endif
40
57
41
58
{- | Derives instance for 'Entity' using type name and field names. Also
42
59
generates type synonim for ID. E.g. code like this:
0 commit comments