|
I have a query with the following type sql :: Query '[] with MySchema '[ 'NotNull 'PGint4] '["id" ::: 'NotNull 'PGint4, "vals" ::: 'NotNull 'PGjsonb]that I then want to turn into a getValues :: Statement MySchema Int32 (Int32, Aeson.Value)
getValues = Query encode decode sql
where
encode = (\x -> x) .* nilParams
decode = (,) <$> #id <*> #valsThis gives me the following error though which confuses me. The schema says the field is |
Answered by
magthe
Sep 8, 2024
Replies: 2 comments 1 reply
|
I posted the same question on the Haskell discourse too. |
0 replies
|
Based on some suggestions on the discourse, and a bit of stubbornness on my side (it just didn't feel like using getValues :: Statement MySchema Int32 (Int32, Aeson.Value)
getValues = Query encode decode sql
where
encode = (\x -> x) .* nilParams
decode = mkResult <$> #id <*> #vals
mkResult id_ vals = (id_, getJsonb vals)Is that a good way to solve it, or is there a more idiomatic way? |
1 reply
Answer selected by
echatav
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on some suggestions on the discourse, and a bit of stubbornness on my side (it just didn't feel like using
JSONBshould require writing my own newtype wrappers, it ought to have support in squeal already) I came up with this modified definition ofgetValues:Is that a good way to solve it, or is there a more idiomatic way?