-
|
I have the following table: And I'm trying to figure out how to insert a user. I have this snippet in a Yesod Handler But I'm getting I thought I might be able to do something like How do I handle this correctly? It seems like a pretty foundational use case. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
|
I think you have a few options:
I'm not sure we have a great story here, but hopefully one of these options will work for you! |
Beta Was this translation helpful? Give feedback.
-
|
I was about to resort to |
Beta Was this translation helpful? Give feedback.
-
|
I'm assuming you meant |
Beta Was this translation helpful? Give feedback.
-
|
Yes 😄 |
Beta Was this translation helpful? Give feedback.
-
|
Could we have a safe coercion operator for this? Something like: coerceExpr :: forall b a . (Coercible a b) => Expr a -> Expr b
coerceExpr = unsafeCoerceExprI think it should be safe because it only works on things that are representationally equal. |
Beta Was this translation helpful? Give feedback.
I think you have a few options:
nextvalwith the type you want.unsafeCoerceExprto castInt64intoUserId.DBNuminstance toUserId, and then you can useRel8.Expr.Num.fromIntegralto castInt64toUserId. This might be a bit unfortunate as it means you can now+UserIds.I'm not sure we have a great story here, but hopefully one of these options will work for you!