Closed thales-maciel closed 1 year ago
@nikita-volkov when I try to use unnest
as per the hasql
documentation but with hasql-th
I get errors around missing instances in vector
(I posted on SO about this).
MVE:
testQuery :: [Text] -> Session [Integer]
testQuery =
flip statement $
dimap
id
(toList . fmap toInteger)
[vectorStatement|
insert into mytable (
title
) (
select * from unnest($1 :: text[])
) returning (id :: int4)
|]
The error I get is:
• No instance for (Data.Vector.Generic.Base.Vector [] Text)
arising from a use of ‘Data.Vector.Generic.foldl'’
• In the first argument of ‘hasql-1.6.3:Hasql.Private.Encoders.dimension’, namely
‘Data.Vector.Generic.foldl'’
In the first argument of ‘hasql-1.6.3:Hasql.Private.Encoders.array’, namely
‘((hasql-1.6.3:Hasql.Private.Encoders.dimension
Data.Vector.Generic.foldl')
(hasql-1.6.3:Hasql.Private.Encoders.element
(hasql-1.6.3:Hasql.Private.Encoders.nonNullable
hasql-1.6.3:Hasql.Private.Encoders.text)))’
In the first argument of ‘hasql-1.6.3:Hasql.Private.Encoders.nonNullable’, namely
‘(hasql-1.6.3:Hasql.Private.Encoders.array
((hasql-1.6.3:Hasql.Private.Encoders.dimension
Data.Vector.Generic.foldl')
(hasql-1.6.3:Hasql.Private.Encoders.element
(hasql-1.6.3:Hasql.Private.Encoders.nonNullable
hasql-1.6.3:Hasql.Private.Encoders.text))))’
Ah nvm it's because I'm mapping using a list not a vector.
I have the following Statement:
how can I insert multiple Xs in the same Statement? I guess I'm missing something