You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
data RecordF = RecordF{
, formatHashes :: V.Vector Text
-- other fields
}
deriving stock (Generic)
deriving anyclass (EncodeRow)
Then corresponding logic to insert this record as a multi-row insert:
bulkInsert :: [RecordF] -> Hasql.Statement () ()
bulkInsertRequestDumps rowsToInsert =
interp
True
[sql| INSERT INTO tableNmae (formatHashes, otherField)
SELECT * from ^{Hasql.toTable rowsToInsert} ON CONFLICT DO NOTHING; |]
This process works fine and nicely (my original record has 30fields, so it saves a lot of boilerplate as well.
But fields like formatHashes are never inserted correctly. I get the following error:
(ResultError (ServerError \"42804\" \"column \\\"format_hashes\\\" is of type text[] but expression is of type text\" Nothing (Just \"You will need to rewrite or cast the expression.\") (Just 407)
Logging the values format hashes appears to be a string that holds the something like: [['abc', 'cde']] but as a string. And I imagine if I could cast it into text[] this would work fine.
INSERT INTO tableNmae (formatHashes, otherField)
SELECT * from unnest($1::text[], $2) ON CONFLICT DO NOTHING;
Is there a workaround to allowing me cast the fields correctly? I don't mind manually writing the numbers. But I would like to maintain the boilerplate encoding which hasql-interpolate does for me.
The text was updated successfully, but these errors were encountered:
I have a record:
Then corresponding logic to insert this record as a multi-row insert:
This process works fine and nicely (my original record has 30fields, so it saves a lot of boilerplate as well.
But fields like formatHashes are never inserted correctly. I get the following error:
Logging the values format hashes appears to be a string that holds the something like:
[['abc', 'cde']]
but as a string. And I imagine if I could cast it into text[] this would work fine.Is there a workaround to allowing me cast the fields correctly? I don't mind manually writing the numbers. But I would like to maintain the boilerplate encoding which hasql-interpolate does for me.
The text was updated successfully, but these errors were encountered: