Closed pjones closed 5 years ago
It would help to see the Email type and how you describe it in YAML.
Sorry about that. Here you go:
data Email = Email
{ emailAddress :: Text
} deriving Show
mkPersist merkelCodegenConfig [groundhog|
embedded: Email
fields:
- name: emailAddress
dbName: email
|]
Where:
merkelCodegenConfig :: CodegenConfig
merkelCodegenConfig = defaultCodegenConfig
{ namingStyle = lowerCaseSuffixNamingStyle
}
Sorry for ignoring the issue for so long. In this case the Groundhog templating logic doesn't have enough data to tell if an embedded type is mapped into one column. A field of type Text
clearly is, but a tuple or another embedded cannot be easily distinguished in compile-time, as the code cannot call dbType
. Mapping to the single column is necessary for making the NeverNull and PrimitivePersistField instances.
In this case the best solution would be to define an instance manually:
instance NeverNull Email
I have an
Email
type that is configured throughmkPersist
as an embedded type. For some of the types in this application I would like to have a record field ofMaybe Email
, but that won"t compile:Is there something in my YAML that needs to change to allow this?