I am defining the following models, where Category
has a non-integer primary key code
of type Text
.
Category
code Text
Primary code
deriving Show Typeable
CategoryTreeNode
name Text
code CategoryId Maybe
lft Int MigrationOnly default=0
rgt Int MigrationOnly default=0
deriving Show Typeable
For models defined without Primary
, I could use toSqlKey
to convert arbitrary Int64
s into Key Category
. Is there an equivalent function for models with custom primary keys?
I found the answer by looking through persistent's TH module:
This line suggest that a CategoryKey
is generated via TH and that is indeed the case:
let x :: Key Category
x = CategoryKey "foobar"