Skip to content

How to use nextval with a newtyped ID? #175

Answered by ocharles
sullyj3 asked this question in Q&A
Discussion options

You must be logged in to vote

I think you have a few options:

  • Define your own version of nextval with the type you want.
  • Use unsafeCoerceExpr to cast Int64 into UserId.
  • Add a DBNum instance to UserId, and then you can use Rel8.Expr.Num.fromIntegral to cast Int64 to UserId. 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!

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ocharles
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #172 on May 19, 2022 06:50.