Closed sullyj3 closed 2 years ago
I think you have a few options:
nextval
with the type you want. unsafeCoerceExpr
to cast Int64
into UserId
.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 +
UserId
s.I'm not sure we have a great story here, but hopefully one of these options will work for you!
I was about to resort to unsafeDefault
, but I think unsafeCoerceExpr
appeals the most. I'll go with that for now. Thanks!
I'm assuming you meant unsafeCastExpr
?
Yes :smile:
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
UserId <$> nextval "user_id_seq"
to obtain anExpr UserId
, but Expr doesn't have a Functor instance. I only have the fuzziest understanding of how expr works, so I assume there's some good reason for this. On reflection this probably doesn't make sense.How do I handle this correctly? It seems like a pretty foundational use case.