-
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 <*> #vals This gives me the following error though
which confuses me. The schema says the field is |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I posted the same question on the Haskell discourse too. |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
Based on some suggestions on the discourse, and a bit of stubbornness on my side (it just didn't feel like using
JSONB
should 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?