Skip to content

Instantly share code, notes, and snippets.

@MaxGabriel
Created January 4, 2020 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaxGabriel/65027cfcea90b68b50e6ba423c619ded to your computer and use it in GitHub Desktop.
Save MaxGabriel/65027cfcea90b68b50e6ba423c619ded to your computer and use it in GitHub Desktop.
test/main.hs:(41,124)-(56,2): Splicing expression
template-haskell-2.14.0.0:Language.Haskell.TH.Quote.quoteExp
persistUpperCase
"\n\
\Person json\n\
\ name Text\n\
\ age Int Maybe\n\
\ foo Foo\n\
\ address Address\n\
\ deriving Show Eq\n\
\Address json\n\
\ street Text\n\
\ city Text\n\
\ zip Int Maybe\n\
\ deriving Show Eq\n\
\NoJson\n\
\ foo Text\n\
\ deriving Show Eq\n"
======>
[((((((((((EntityDef (HaskellName (pack "Person")))
(DBName (pack "Person")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "PersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Person")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for name")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for age")))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "foo"))) (DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Foo")))
(SqlOther (pack "SqlType unset for foo")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Address")))
(SqlOther (pack "SqlType unset for address")))
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Address")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "foo"))) (DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Foo")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Foo)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Address")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Address")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "PersonId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Person")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing},
((((((((((EntityDef (HaskellName (pack "Address")))
(DBName (pack "Address")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "AddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Address")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for street")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for city")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for zip")))
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "AddressId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Address")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing},
((((((((((EntityDef (HaskellName (pack "NoJson")))
(DBName (pack "NoJson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "NoJsonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "NoJson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[])
[(((((((FieldDef (HaskellName (pack "foo"))) (DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for foo")))
[])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "foo")))
(DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "NoJsonId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "NoJson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing}]
test/main.hs:(41,1)-(56,2): Splicing declarations
share
[mkPersist sqlSettings {mpsGeneric = False},
mkDeleteCascade sqlSettings {mpsGeneric = False}]
([((((((((((EntityDef (HaskellName (pack "Person")))
(DBName (pack "Person")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "PersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Person")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for name")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for age")))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "foo"))) (DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Foo")))
(SqlOther (pack "SqlType unset for foo")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Address")))
(SqlOther (pack "SqlType unset for address")))
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Address")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "foo"))) (DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Foo")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Foo)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Address")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Address")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "PersonId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Person")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing},
((((((((((EntityDef (HaskellName (pack "Address")))
(DBName (pack "Address")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "AddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Address")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for street")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for city")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for zip")))
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "AddressId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Address")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing},
((((((((((EntityDef (HaskellName (pack "NoJson")))
(DBName (pack "NoJson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "NoJsonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "NoJson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[])
[(((((((FieldDef (HaskellName (pack "foo"))) (DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for foo")))
[])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "foo")))
(DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "NoJsonId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "NoJson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing}])
======>
instance PersistField Person where
toPersistValue
= \ ent_aus1
-> (PersistMap
$ (zip ((map pack) ["name", "age", "foo", "address"]))
(map toPersistValue $ toPersistFields ent_aus1))
fromPersistValue
= ((\ x_aus2
-> let
columns_aus3
= unordered-containers-0.2.10.0:Data.HashMap.Strict.Base.fromList
x_aus2
in
(fromPersistValues
$ (map
(\ name_aus4
-> case
(unordered-containers-0.2.10.0:Data.HashMap.Base.lookup
(pack name_aus4))
columns_aus3
of
Just v_aus5 -> v_aus5
Nothing -> PersistNull)
$ ["name", "age", "foo", "address"])))
Control.Monad.<=< getPersistMap)
instance persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql Person where
persistent-2.10.4:Database.Persist.Sql.Class.sqlType _ = SqlString
instance PersistField Address where
toPersistValue
= \ ent_aus6
-> (PersistMap
$ (zip ((map pack) ["street", "city", "zip"]))
(map toPersistValue $ toPersistFields ent_aus6))
fromPersistValue
= ((\ x_aus7
-> let
columns_aus8
= unordered-containers-0.2.10.0:Data.HashMap.Strict.Base.fromList
x_aus7
in
(fromPersistValues
$ (map
(\ name_aus9
-> case
(unordered-containers-0.2.10.0:Data.HashMap.Base.lookup
(pack name_aus9))
columns_aus8
of
Just v_ausa -> v_ausa
Nothing -> PersistNull)
$ ["street", "city", "zip"])))
Control.Monad.<=< getPersistMap)
instance persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql Address where
persistent-2.10.4:Database.Persist.Sql.Class.sqlType _ = SqlString
instance PersistField NoJson where
toPersistValue
= \ ent_ausb
-> (PersistMap
$ (zip ((map pack) ["foo"]))
(map toPersistValue $ toPersistFields ent_ausb))
fromPersistValue
= ((\ x_ausc
-> let
columns_ausd
= unordered-containers-0.2.10.0:Data.HashMap.Strict.Base.fromList
x_ausc
in
(fromPersistValues
$ (map
(\ name_ause
-> case
(unordered-containers-0.2.10.0:Data.HashMap.Base.lookup
(pack name_ause))
columns_ausd
of
Just v_ausf -> v_ausf
Nothing -> PersistNull)
$ ["foo"])))
Control.Monad.<=< getPersistMap)
instance persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql NoJson where
persistent-2.10.4:Database.Persist.Sql.Class.sqlType _ = SqlString
data Person
= Person {personName :: !Text,
personAge :: !(Maybe Int),
personFoo :: !Foo,
personAddress :: !Address}
deriving (Show, Eq)
type PersonId = Key Person
instance PersistEntity Person where
type PersistEntityBackend Person = Database.Persist.Sql.Types.Internal.SqlBackend
data Unique Person
newtype Key Person
= PersonKey {unPersonKey :: (BackendKey Database.Persist.Sql.Types.Internal.SqlBackend)}
deriving newtype (Show,
Read,
Eq,
Ord,
path-pieces-0.2.1:Web.PathPieces.PathPiece,
http-api-data-0.4.1:Web.Internal.HttpApiData.ToHttpApiData,
http-api-data-0.4.1:Web.Internal.HttpApiData.FromHttpApiData,
PersistField,
persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql,
ToJSON,
FromJSON)
data EntityField Person typ
= typ ~ Key Person => PersonId |
typ ~ Text => PersonName |
typ ~ Maybe Int => PersonAge |
typ ~ Foo => PersonFoo |
typ ~ Address => PersonAddress
keyToValues = ((: []) . (toPersistValue . unPersonKey))
keyFromValues
= (fmap PersonKey
. (fromPersistValue . Database.Persist.TH.headNote))
entityDef _
= ((((((((((EntityDef (HaskellName (pack "Person")))
(DBName (pack "Person")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "PersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Person")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "foo"))) (DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Foo")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Address")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Address")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
toPersistFields (Person x_ausg x_aush x_ausi x_ausj)
= [SomePersistField x_ausg, SomePersistField x_aush,
SomePersistField x_ausi, SomePersistField x_ausj]
fromPersistValues [x1_ausl, x2_ausm, x3_ausn, x4_auso]
= Person
<$>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "Person")) (pack "name"))
. fromPersistValue)
x1_ausl
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "Person")) (pack "age"))
. fromPersistValue)
x2_ausm
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "Person")) (pack "foo"))
. fromPersistValue)
x3_ausn
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "Person")) (pack "address"))
. fromPersistValue)
x4_auso
fromPersistValues x_ausk
= (Left
$ (mappend (pack "Person: fromPersistValues failed on: "))
(pack $ show x_ausk))
persistUniqueToFieldNames _
= error "Degenerate case, should never happen"
persistUniqueToValues _
= error "Degenerate case, should never happen"
persistUniqueKeys
(Person _name_ausp _age_ausq _foo_ausr _address_auss)
= []
persistFieldDef PersonId
= (((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "PersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Person")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing
persistFieldDef PersonName
= (((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing
persistFieldDef PersonAge
= (((((((FieldDef (HaskellName (pack "age")))
(DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing
persistFieldDef PersonFoo
= (((((((FieldDef (HaskellName (pack "foo")))
(DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Foo")))
SqlString)
[])
True)
NoReference)
Nothing
persistFieldDef PersonAddress
= (((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Address")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Address")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing
persistIdField = PersonId
fieldLens PersonId
= (lensPTH entityKey)
(\ (Entity _ value_aust) key_ausu -> (Entity key_ausu) value_aust)
fieldLens PersonName
= (lensPTH (personName . entityVal))
(\ (Entity key_ausv value_ausw) x_ausx
-> (Entity key_ausv) value_ausw {personName = x_ausx})
fieldLens PersonAge
= (lensPTH (personAge . entityVal))
(\ (Entity key_ausv value_ausw) x_ausx
-> (Entity key_ausv) value_ausw {personAge = x_ausx})
fieldLens PersonFoo
= (lensPTH (personFoo . entityVal))
(\ (Entity key_ausv value_ausw) x_ausx
-> (Entity key_ausv) value_ausw {personFoo = x_ausx})
fieldLens PersonAddress
= (lensPTH (personAddress . entityVal))
(\ (Entity key_ausv value_ausw) x_ausx
-> (Entity key_ausv) value_ausw {personAddress = x_ausx})
instance ToBackendKey Database.Persist.Sql.Types.Internal.SqlBackend Person where
toBackendKey = unPersonKey
fromBackendKey = PersonKey
data Address
= Address {addressStreet :: !Text,
addressCity :: !Text,
addressZip :: !(Maybe Int)}
deriving (Show, Eq)
type AddressId = Key Address
instance PersistEntity Address where
type PersistEntityBackend Address = Database.Persist.Sql.Types.Internal.SqlBackend
data Unique Address
newtype Key Address
= AddressKey {unAddressKey :: (BackendKey Database.Persist.Sql.Types.Internal.SqlBackend)}
deriving newtype (Show,
Read,
Eq,
Ord,
path-pieces-0.2.1:Web.PathPieces.PathPiece,
http-api-data-0.4.1:Web.Internal.HttpApiData.ToHttpApiData,
http-api-data-0.4.1:Web.Internal.HttpApiData.FromHttpApiData,
PersistField,
persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql,
ToJSON,
FromJSON)
data EntityField Address typ
= typ ~ Key Address => AddressId |
typ ~ Text => AddressStreet |
typ ~ Text => AddressCity |
typ ~ Maybe Int => AddressZip
keyToValues = ((: []) . (toPersistValue . unAddressKey))
keyFromValues
= (fmap AddressKey
. (fromPersistValue . Database.Persist.TH.headNote))
entityDef _
= ((((((((((EntityDef (HaskellName (pack "Address")))
(DBName (pack "Address")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "AddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Address")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
toPersistFields (Address x_ausy x_ausz x_ausA)
= [SomePersistField x_ausy, SomePersistField x_ausz,
SomePersistField x_ausA]
fromPersistValues [x1_ausC, x2_ausD, x3_ausE]
= Address
<$>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "Address")) (pack "street"))
. fromPersistValue)
x1_ausC
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "Address")) (pack "city"))
. fromPersistValue)
x2_ausD
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "Address")) (pack "zip"))
. fromPersistValue)
x3_ausE
fromPersistValues x_ausB
= (Left
$ (mappend (pack "Address: fromPersistValues failed on: "))
(pack $ show x_ausB))
persistUniqueToFieldNames _
= error "Degenerate case, should never happen"
persistUniqueToValues _
= error "Degenerate case, should never happen"
persistUniqueKeys (Address _street_ausF _city_ausG _zip_ausH) = []
persistFieldDef AddressId
= (((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "AddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Address")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing
persistFieldDef AddressStreet
= (((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing
persistFieldDef AddressCity
= (((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing
persistFieldDef AddressZip
= (((((((FieldDef (HaskellName (pack "zip")))
(DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing
persistIdField = AddressId
fieldLens AddressId
= (lensPTH entityKey)
(\ (Entity _ value_ausI) key_ausJ -> (Entity key_ausJ) value_ausI)
fieldLens AddressStreet
= (lensPTH (addressStreet . entityVal))
(\ (Entity key_ausK value_ausL) x_ausM
-> (Entity key_ausK) value_ausL {addressStreet = x_ausM})
fieldLens AddressCity
= (lensPTH (addressCity . entityVal))
(\ (Entity key_ausK value_ausL) x_ausM
-> (Entity key_ausK) value_ausL {addressCity = x_ausM})
fieldLens AddressZip
= (lensPTH (addressZip . entityVal))
(\ (Entity key_ausK value_ausL) x_ausM
-> (Entity key_ausK) value_ausL {addressZip = x_ausM})
instance ToBackendKey Database.Persist.Sql.Types.Internal.SqlBackend Address where
toBackendKey = unAddressKey
fromBackendKey = AddressKey
data NoJson
= NoJson {noJsonFoo :: !Text}
deriving (Show, Eq)
type NoJsonId = Key NoJson
instance PersistEntity NoJson where
type PersistEntityBackend NoJson = Database.Persist.Sql.Types.Internal.SqlBackend
data Unique NoJson
newtype Key NoJson
= NoJsonKey {unNoJsonKey :: (BackendKey Database.Persist.Sql.Types.Internal.SqlBackend)}
deriving newtype (Show,
Read,
Eq,
Ord,
path-pieces-0.2.1:Web.PathPieces.PathPiece,
http-api-data-0.4.1:Web.Internal.HttpApiData.ToHttpApiData,
http-api-data-0.4.1:Web.Internal.HttpApiData.FromHttpApiData,
PersistField,
persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql,
ToJSON,
FromJSON)
data EntityField NoJson typ
= typ ~ Key NoJson => NoJsonId | typ ~ Text => NoJsonFoo
keyToValues = ((: []) . (toPersistValue . unNoJsonKey))
keyFromValues
= (fmap NoJsonKey
. (fromPersistValue . Database.Persist.TH.headNote))
entityDef _
= ((((((((((EntityDef (HaskellName (pack "NoJson")))
(DBName (pack "NoJson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "NoJsonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "NoJson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[])
[(((((((FieldDef (HaskellName (pack "foo"))) (DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
toPersistFields (NoJson x_ausN) = [SomePersistField x_ausN]
fromPersistValues [x1_ausP]
= NoJson
<$>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "NoJson")) (pack "foo"))
. fromPersistValue)
x1_ausP
fromPersistValues x_ausO
= (Left
$ (mappend (pack "NoJson: fromPersistValues failed on: "))
(pack $ show x_ausO))
persistUniqueToFieldNames _
= error "Degenerate case, should never happen"
persistUniqueToValues _
= error "Degenerate case, should never happen"
persistUniqueKeys (NoJson _foo_ausQ) = []
persistFieldDef NoJsonId
= (((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "NoJsonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "NoJson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing
persistFieldDef NoJsonFoo
= (((((((FieldDef (HaskellName (pack "foo")))
(DBName (pack "foo")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing
persistIdField = NoJsonId
fieldLens NoJsonId
= (lensPTH entityKey)
(\ (Entity _ value_ausR) key_ausS -> (Entity key_ausS) value_ausR)
fieldLens NoJsonFoo
= (lensPTH (noJsonFoo . entityVal))
(\ (Entity key_ausT value_ausU) x_ausV
-> (Entity key_ausT) value_ausU {noJsonFoo = x_ausV})
instance ToBackendKey Database.Persist.Sql.Types.Internal.SqlBackend NoJson where
toBackendKey = unNoJsonKey
fromBackendKey = NoJsonKey
instance ToJSON Person where
toJSON (Person name_ausX age_ausY foo_ausZ address_aut0)
= object
[(pack "name" .= name_ausX), (pack "age" .= age_ausY),
(pack "foo" .= foo_ausZ), (pack "address" .= address_aut0)]
instance FromJSON Person where
parseJSON (Object obj_ausW)
= ((((pure Person <*> (obj_ausW .: pack "name"))
<*> (obj_ausW .:? pack "age"))
<*> (obj_ausW .: pack "foo"))
<*> (obj_ausW .: pack "address"))
parseJSON _ = GHC.Base.mzero
instance ToJSON (Entity Person) where
toJSON = entityIdToJSON
instance FromJSON (Entity Person) where
parseJSON = entityIdFromJSON
instance ToJSON Address where
toJSON (Address street_aut2 city_aut3 zip_aut4)
= object
[(pack "street" .= street_aut2), (pack "city" .= city_aut3),
(pack "zip" .= zip_aut4)]
instance FromJSON Address where
parseJSON (Object obj_aut1)
= (((pure Address <*> (obj_aut1 .: pack "street"))
<*> (obj_aut1 .: pack "city"))
<*> (obj_aut1 .:? pack "zip"))
parseJSON _ = GHC.Base.mzero
instance ToJSON (Entity Address) where
toJSON = entityIdToJSON
instance FromJSON (Entity Address) where
parseJSON = entityIdFromJSON
instance GHC.TypeLits.TypeError (NoUniqueKeysError Person) =>
OnlyOneUniqueKey Person where
onlyUniqueP _ = error "impossible"
instance GHC.TypeLits.TypeError (MultipleUniqueKeysError Person) =>
AtLeastOneUniqueKey Person where
requireUniquesP _ = error "impossible"
instance GHC.TypeLits.TypeError (NoUniqueKeysError Address) =>
OnlyOneUniqueKey Address where
onlyUniqueP _ = error "impossible"
instance GHC.TypeLits.TypeError (MultipleUniqueKeysError Address) =>
AtLeastOneUniqueKey Address where
requireUniquesP _ = error "impossible"
instance GHC.TypeLits.TypeError (NoUniqueKeysError NoJson) =>
OnlyOneUniqueKey NoJson where
onlyUniqueP _ = error "impossible"
instance GHC.TypeLits.TypeError (MultipleUniqueKeysError NoJson) =>
AtLeastOneUniqueKey NoJson where
requireUniquesP _ = error "impossible"
instance (PersistQuery backend,
PersistEntityBackend Person ~ BaseBackend backend) =>
DeleteCascade Person backend where
deleteCascade key_aut5 = do delete key_aut5
instance (PersistQuery backend,
PersistEntityBackend Address ~ BaseBackend backend) =>
DeleteCascade Address backend where
deleteCascade key_aut6 = do delete key_aut6
instance (PersistQuery backend,
PersistEntityBackend NoJson ~ BaseBackend backend) =>
DeleteCascade NoJson backend where
deleteCascade key_aut7 = do delete key_aut7
test/main.hs:(58,98)-(69,2): Splicing expression
template-haskell-2.14.0.0:Language.Haskell.TH.Quote.quoteExp
persistLowerCase
"\n\
\Lperson json\n\
\ name Text\n\
\ age Int Maybe\n\
\ address Laddress\n\
\ deriving Show Eq\n\
\Laddress json\n\
\ street Text\n\
\ city Text\n\
\ zip Int Maybe\n\
\ deriving Show Eq\n"
======>
[((((((((((EntityDef (HaskellName (pack "Lperson")))
(DBName (pack "lperson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "LpersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Lperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for name")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for age")))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Laddress")))
(SqlOther (pack "SqlType unset for address")))
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Laddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Laddress")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Laddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "LpersonId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Lperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing},
((((((((((EntityDef (HaskellName (pack "Laddress")))
(DBName (pack "laddress")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "LaddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Laddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for street")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for city")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for zip")))
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "LaddressId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Laddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing}]
test/main.hs:(58,1)-(69,2): Splicing declarations
share
[mkPersist
sqlSettings {mpsGeneric = False, mpsGenerateLenses = True}]
([((((((((((EntityDef (HaskellName (pack "Lperson")))
(DBName (pack "lperson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "LpersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Lperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for name")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for age")))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Laddress")))
(SqlOther (pack "SqlType unset for address")))
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Laddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Laddress")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Laddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "LpersonId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Lperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing},
((((((((((EntityDef (HaskellName (pack "Laddress")))
(DBName (pack "laddress")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "LaddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Laddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for street")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for city")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for zip")))
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "LaddressId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Laddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing}])
======>
instance PersistField Lperson where
toPersistValue
= \ ent_azQS
-> (PersistMap
$ (zip ((map pack) ["name", "age", "address"]))
(map toPersistValue $ toPersistFields ent_azQS))
fromPersistValue
= ((\ x_azQT
-> let
columns_azQU
= unordered-containers-0.2.10.0:Data.HashMap.Strict.Base.fromList
x_azQT
in
(fromPersistValues
$ (map
(\ name_azQV
-> case
(unordered-containers-0.2.10.0:Data.HashMap.Base.lookup
(pack name_azQV))
columns_azQU
of
Just v_azQW -> v_azQW
Nothing -> PersistNull)
$ ["name", "age", "address"])))
Control.Monad.<=< getPersistMap)
instance persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql Lperson where
persistent-2.10.4:Database.Persist.Sql.Class.sqlType _ = SqlString
instance PersistField Laddress where
toPersistValue
= \ ent_azQX
-> (PersistMap
$ (zip ((map pack) ["street", "city", "zip"]))
(map toPersistValue $ toPersistFields ent_azQX))
fromPersistValue
= ((\ x_azQY
-> let
columns_azQZ
= unordered-containers-0.2.10.0:Data.HashMap.Strict.Base.fromList
x_azQY
in
(fromPersistValues
$ (map
(\ name_azR0
-> case
(unordered-containers-0.2.10.0:Data.HashMap.Base.lookup
(pack name_azR0))
columns_azQZ
of
Just v_azR1 -> v_azR1
Nothing -> PersistNull)
$ ["street", "city", "zip"])))
Control.Monad.<=< getPersistMap)
instance persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql Laddress where
persistent-2.10.4:Database.Persist.Sql.Class.sqlType _ = SqlString
data Lperson
= Lperson {_lpersonName :: !Text,
_lpersonAge :: !(Maybe Int),
_lpersonAddress :: !Laddress}
deriving (Show, Eq)
type LpersonId = Key Lperson
instance PersistEntity Lperson where
type PersistEntityBackend Lperson = Database.Persist.Sql.Types.Internal.SqlBackend
data Unique Lperson
newtype Key Lperson
= LpersonKey {unLpersonKey :: (BackendKey Database.Persist.Sql.Types.Internal.SqlBackend)}
deriving newtype (Show,
Read,
Eq,
Ord,
path-pieces-0.2.1:Web.PathPieces.PathPiece,
http-api-data-0.4.1:Web.Internal.HttpApiData.ToHttpApiData,
http-api-data-0.4.1:Web.Internal.HttpApiData.FromHttpApiData,
PersistField,
persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql,
ToJSON,
FromJSON)
data EntityField Lperson typ
= typ ~ Key Lperson => LpersonId |
typ ~ Text => LpersonName |
typ ~ Maybe Int => LpersonAge |
typ ~ Laddress => LpersonAddress
keyToValues = ((: []) . (toPersistValue . unLpersonKey))
keyFromValues
= (fmap LpersonKey
. (fromPersistValue . Database.Persist.TH.headNote))
entityDef _
= ((((((((((EntityDef (HaskellName (pack "Lperson")))
(DBName (pack "lperson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "LpersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Lperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Laddress")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Laddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
toPersistFields (Lperson x_azR2 x_azR3 x_azR4)
= [SomePersistField x_azR2, SomePersistField x_azR3,
SomePersistField x_azR4]
fromPersistValues [x1_azR6, x2_azR7, x3_azR8]
= Lperson
<$>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "lperson")) (pack "name"))
. fromPersistValue)
x1_azR6
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "lperson")) (pack "age"))
. fromPersistValue)
x2_azR7
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "lperson"))
(pack "address"))
. fromPersistValue)
x3_azR8
fromPersistValues x_azR5
= (Left
$ (mappend (pack "Lperson: fromPersistValues failed on: "))
(pack $ show x_azR5))
persistUniqueToFieldNames _
= error "Degenerate case, should never happen"
persistUniqueToValues _
= error "Degenerate case, should never happen"
persistUniqueKeys (Lperson _name_azR9 _age_azRa _address_azRb) = []
persistFieldDef LpersonId
= (((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "LpersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Lperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing
persistFieldDef LpersonName
= (((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing
persistFieldDef LpersonAge
= (((((((FieldDef (HaskellName (pack "age")))
(DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing
persistFieldDef LpersonAddress
= (((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Laddress")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Laddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing
persistIdField = LpersonId
fieldLens LpersonId
= (lensPTH entityKey)
(\ (Entity _ value_azRc) key_azRd -> (Entity key_azRd) value_azRc)
fieldLens LpersonName
= (lensPTH (_lpersonName . entityVal))
(\ (Entity key_azRe value_azRf) x_azRg
-> (Entity key_azRe) value_azRf {_lpersonName = x_azRg})
fieldLens LpersonAge
= (lensPTH (_lpersonAge . entityVal))
(\ (Entity key_azRe value_azRf) x_azRg
-> (Entity key_azRe) value_azRf {_lpersonAge = x_azRg})
fieldLens LpersonAddress
= (lensPTH (_lpersonAddress . entityVal))
(\ (Entity key_azRe value_azRf) x_azRg
-> (Entity key_azRe) value_azRf {_lpersonAddress = x_azRg})
lpersonName ::
forall f. Functor f => (Text -> f Text) -> Lperson -> f Lperson
lpersonName f_azRj a_azRk
= (fmap setter_azRi) (f_azRj needle_azRh)
where
needle_azRh = _lpersonName a_azRk
setter_azRi y_azRl = a_azRk {_lpersonName = y_azRl}
lpersonAge ::
forall f.
Functor f => (Maybe Int -> f (Maybe Int)) -> Lperson -> f Lperson
lpersonAge f_azRo a_azRp
= (fmap setter_azRn) (f_azRo needle_azRm)
where
needle_azRm = _lpersonAge a_azRp
setter_azRn y_azRq = a_azRp {_lpersonAge = y_azRq}
lpersonAddress ::
forall f.
Functor f => (Laddress -> f Laddress) -> Lperson -> f Lperson
lpersonAddress f_azRt a_azRu
= (fmap setter_azRs) (f_azRt needle_azRr)
where
needle_azRr = _lpersonAddress a_azRu
setter_azRs y_azRv = a_azRu {_lpersonAddress = y_azRv}
instance ToBackendKey Database.Persist.Sql.Types.Internal.SqlBackend Lperson where
toBackendKey = unLpersonKey
fromBackendKey = LpersonKey
data Laddress
= Laddress {_laddressStreet :: !Text,
_laddressCity :: !Text,
_laddressZip :: !(Maybe Int)}
deriving (Show, Eq)
type LaddressId = Key Laddress
instance PersistEntity Laddress where
type PersistEntityBackend Laddress = Database.Persist.Sql.Types.Internal.SqlBackend
data Unique Laddress
newtype Key Laddress
= LaddressKey {unLaddressKey :: (BackendKey Database.Persist.Sql.Types.Internal.SqlBackend)}
deriving newtype (Show,
Read,
Eq,
Ord,
path-pieces-0.2.1:Web.PathPieces.PathPiece,
http-api-data-0.4.1:Web.Internal.HttpApiData.ToHttpApiData,
http-api-data-0.4.1:Web.Internal.HttpApiData.FromHttpApiData,
PersistField,
persistent-2.10.4:Database.Persist.Sql.Class.PersistFieldSql,
ToJSON,
FromJSON)
data EntityField Laddress typ
= typ ~ Key Laddress => LaddressId |
typ ~ Text => LaddressStreet |
typ ~ Text => LaddressCity |
typ ~ Maybe Int => LaddressZip
keyToValues = ((: []) . (toPersistValue . unLaddressKey))
keyFromValues
= (fmap LaddressKey
. (fromPersistValue . Database.Persist.TH.headNote))
entityDef _
= ((((((((((EntityDef (HaskellName (pack "Laddress")))
(DBName (pack "laddress")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "LaddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Laddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
toPersistFields (Laddress x_azRw x_azRx x_azRy)
= [SomePersistField x_azRw, SomePersistField x_azRx,
SomePersistField x_azRy]
fromPersistValues [x1_azRA, x2_azRB, x3_azRC]
= Laddress
<$>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "laddress"))
(pack "street"))
. fromPersistValue)
x1_azRA
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "laddress")) (pack "city"))
. fromPersistValue)
x2_azRB
<*>
(Database.Persist.TH.mapLeft
((Database.Persist.TH.fieldError (pack "laddress")) (pack "zip"))
. fromPersistValue)
x3_azRC
fromPersistValues x_azRz
= (Left
$ (mappend (pack "Laddress: fromPersistValues failed on: "))
(pack $ show x_azRz))
persistUniqueToFieldNames _
= error "Degenerate case, should never happen"
persistUniqueToValues _
= error "Degenerate case, should never happen"
persistUniqueKeys (Laddress _street_azRD _city_azRE _zip_azRF) = []
persistFieldDef LaddressId
= (((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "LaddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Laddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing
persistFieldDef LaddressStreet
= (((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing
persistFieldDef LaddressCity
= (((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing
persistFieldDef LaddressZip
= (((((((FieldDef (HaskellName (pack "zip")))
(DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing
persistIdField = LaddressId
fieldLens LaddressId
= (lensPTH entityKey)
(\ (Entity _ value_azRG) key_azRH -> (Entity key_azRH) value_azRG)
fieldLens LaddressStreet
= (lensPTH (_laddressStreet . entityVal))
(\ (Entity key_azRI value_azRJ) x_azRK
-> (Entity key_azRI) value_azRJ {_laddressStreet = x_azRK})
fieldLens LaddressCity
= (lensPTH (_laddressCity . entityVal))
(\ (Entity key_azRI value_azRJ) x_azRK
-> (Entity key_azRI) value_azRJ {_laddressCity = x_azRK})
fieldLens LaddressZip
= (lensPTH (_laddressZip . entityVal))
(\ (Entity key_azRI value_azRJ) x_azRK
-> (Entity key_azRI) value_azRJ {_laddressZip = x_azRK})
laddressStreet ::
forall f. Functor f => (Text -> f Text) -> Laddress -> f Laddress
laddressStreet f_azRN a_azRO
= (fmap setter_azRM) (f_azRN needle_azRL)
where
needle_azRL = _laddressStreet a_azRO
setter_azRM y_azRP = a_azRO {_laddressStreet = y_azRP}
laddressCity ::
forall f. Functor f => (Text -> f Text) -> Laddress -> f Laddress
laddressCity f_azRS a_azRT
= (fmap setter_azRR) (f_azRS needle_azRQ)
where
needle_azRQ = _laddressCity a_azRT
setter_azRR y_azRU = a_azRT {_laddressCity = y_azRU}
laddressZip ::
forall f.
Functor f => (Maybe Int -> f (Maybe Int)) -> Laddress -> f Laddress
laddressZip f_azRX a_azRY
= (fmap setter_azRW) (f_azRX needle_azRV)
where
needle_azRV = _laddressZip a_azRY
setter_azRW y_azRZ = a_azRY {_laddressZip = y_azRZ}
instance ToBackendKey Database.Persist.Sql.Types.Internal.SqlBackend Laddress where
toBackendKey = unLaddressKey
fromBackendKey = LaddressKey
instance ToJSON Lperson where
toJSON (Lperson name_azS1 age_azS2 address_azS3)
= object
[(pack "name" .= name_azS1), (pack "age" .= age_azS2),
(pack "address" .= address_azS3)]
instance FromJSON Lperson where
parseJSON (Object obj_azS0)
= (((pure Lperson <*> (obj_azS0 .: pack "name"))
<*> (obj_azS0 .:? pack "age"))
<*> (obj_azS0 .: pack "address"))
parseJSON _ = GHC.Base.mzero
instance ToJSON (Entity Lperson) where
toJSON = entityIdToJSON
instance FromJSON (Entity Lperson) where
parseJSON = entityIdFromJSON
instance ToJSON Laddress where
toJSON (Laddress street_azS5 city_azS6 zip_azS7)
= object
[(pack "street" .= street_azS5), (pack "city" .= city_azS6),
(pack "zip" .= zip_azS7)]
instance FromJSON Laddress where
parseJSON (Object obj_azS4)
= (((pure Laddress <*> (obj_azS4 .: pack "street"))
<*> (obj_azS4 .: pack "city"))
<*> (obj_azS4 .:? pack "zip"))
parseJSON _ = GHC.Base.mzero
instance ToJSON (Entity Laddress) where
toJSON = entityIdToJSON
instance FromJSON (Entity Laddress) where
parseJSON = entityIdFromJSON
instance GHC.TypeLits.TypeError (NoUniqueKeysError Lperson) =>
OnlyOneUniqueKey Lperson where
onlyUniqueP _ = error "impossible"
instance GHC.TypeLits.TypeError (MultipleUniqueKeysError Lperson) =>
AtLeastOneUniqueKey Lperson where
requireUniquesP _ = error "impossible"
instance GHC.TypeLits.TypeError (NoUniqueKeysError Laddress) =>
OnlyOneUniqueKey Laddress where
onlyUniqueP _ = error "impossible"
instance GHC.TypeLits.TypeError (MultipleUniqueKeysError Laddress) =>
AtLeastOneUniqueKey Laddress where
requireUniquesP _ = error "impossible"
test/Migrate.hs:(25,61)-(36,2): Splicing expression
template-haskell-2.14.0.0:Language.Haskell.TH.Quote.quoteExp
persistLowerCase
"\n\
\Mperson json\n\
\ name Text\n\
\ age Int Maybe\n\
\ address Maddress\n\
\ deriving Show Eq\n\
\Maddress json\n\
\ street Text\n\
\ city Text\n\
\ zip Int Maybe\n\
\ deriving Show Eq\n"
======>
[((((((((((EntityDef (HaskellName (pack "Mperson")))
(DBName (pack "mperson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "MpersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Mperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for name")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for age")))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Maddress")))
(SqlOther (pack "SqlType unset for address")))
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Maddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Maddress")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Maddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "MpersonId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Mperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing},
((((((((((EntityDef (HaskellName (pack "Maddress")))
(DBName (pack "maddress")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "MaddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Maddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for street")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for city")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for zip")))
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "MaddressId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Maddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing}]
test/Migrate.hs:(25,1)-(36,2): Splicing declarations
share
[mkMigrate "getRequiredMigrations"]
([((((((((((EntityDef (HaskellName (pack "Mperson")))
(DBName (pack "mperson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "MpersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Mperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for name")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for age")))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Maddress")))
(SqlOther (pack "SqlType unset for address")))
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Maddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Maddress")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Maddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "MpersonId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Mperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing},
((((((((((EntityDef (HaskellName (pack "Maddress")))
(DBName (pack "maddress")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "MaddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Maddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for street")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(SqlOther (pack "SqlType unset for city")))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(SqlOther (pack "SqlType unset for zip")))
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing
{entityFields = [(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Text)))
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy Int)))
[pack "Maybe"])
True)
NoReference)
Nothing],
entityId = (((((((FieldDef (HaskellName (pack "Id")))
(DBName (pack "id")))
((FTTypeCon Nothing) (pack "MaddressId")))
(persistent-2.10.4:Database.Persist.Sql.Class.sqlType
(Data.Proxy.Proxy :: Data.Proxy.Proxy GHC.Int.Int64)))
[])
True)
((ForeignRef (HaskellName (pack "Maddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing}])
======>
getRequiredMigrations ::
persistent-2.10.4:Database.Persist.Sql.Types.Migration
getRequiredMigrations
= do let defs_argP
= [((((((((((EntityDef (HaskellName (pack "Mperson")))
(DBName (pack "mperson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "MpersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Mperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Maddress")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Maddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing,
((((((((((EntityDef (HaskellName (pack "Maddress")))
(DBName (pack "maddress")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "MaddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Maddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing]
(persistent-2.10.4:Database.Persist.Sql.Migration.migrate
defs_argP)
(((((((((((EntityDef (HaskellName (pack "Mperson")))
(DBName (pack "mperson")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "MpersonId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Mperson")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "name")))
(DBName (pack "name")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "age"))) (DBName (pack "age")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "address")))
(DBName (pack "address")))
((FTTypeCon Nothing) (pack "Maddress")))
SqlString)
[])
True)
(EmbedRef
((EmbedEntityDef (HaskellName (pack "Maddress")))
[((EmbedFieldDef (DBName (pack "street"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "city"))) Nothing) Nothing,
((EmbedFieldDef (DBName (pack "zip"))) Nothing) Nothing])))
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing)
(persistent-2.10.4:Database.Persist.Sql.Migration.migrate
defs_argP)
(((((((((((EntityDef (HaskellName (pack "Maddress")))
(DBName (pack "maddress")))
((((((((FieldDef (HaskellName (pack "Id"))) (DBName (pack "id")))
((FTTypeCon Nothing) (pack "MaddressId")))
SqlInt64)
[])
True)
((ForeignRef (HaskellName (pack "Maddress")))
((FTTypeCon (Just (pack "Data.Int"))) (pack "Int64"))))
Nothing))
[pack "json"])
[(((((((FieldDef (HaskellName (pack "street")))
(DBName (pack "street")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "city")))
(DBName (pack "city")))
((FTTypeCon Nothing) (pack "Text")))
SqlString)
[])
True)
NoReference)
Nothing,
(((((((FieldDef (HaskellName (pack "zip"))) (DBName (pack "zip")))
((FTTypeCon Nothing) (pack "Int")))
SqlInt64)
[pack "Maybe"])
True)
NoReference)
Nothing])
[])
[])
[pack "Show", pack "Eq"])
(containers-0.6.0.1:Data.Map.Internal.fromList []))
False)
Nothing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment