@@ -7,6 +7,7 @@ import Prelude
77
88import Data.Default
99import Data.String
10+ import Data.Text (pack , unpack )
1011import Database.PostgreSQL.Query.Entity.Class
1112import Database.PostgreSQL.Query.TH.Common
1213import Database.PostgreSQL.Query.Types ( FN (.. ) )
@@ -29,6 +30,7 @@ data EntityOptions = EntityOptions
2930 , eoIdType :: Name -- ^ Base type for Id
3031 } deriving (Generic )
3132
33+ #if !MIN_VERSION_inflections(0,3,0)
3234instance Default EntityOptions where
3335 def = EntityOptions
3436 { eoTableName = toUnderscore
@@ -37,6 +39,21 @@ instance Default EntityOptions where
3739 , ''FromField, ''ToField ]
3840 , eoIdType = ''Integer
3941 }
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
4057
4158{- | Derives instance for 'Entity' using type name and field names. Also
4259generates type synonim for ID. E.g. code like this:
0 commit comments