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
I'm trying to batch a insert of multiple rows with the following query (PostgreSQL):
INSERT INTO instances (instance_hash, workflow_hash)
SELECT i, w FROM unnest($1::BYTEA[], $2::BYTEA[]) as x(i,w)
ON CONFLICT (instance_hash) DO NOTHING
I'm getting the following error: unsupported type BYTEA[] for param #1
I'm using the query! macro to do it and check the query. Is there a way to do it without doing it unchecked?
The text was updated successfully, but these errors were encountered:
@augustocdias it's not exactly optimal but you could pass hex encoded strings in and decode them in Postgres:
INSERT INTO instances (instance_hash, workflow_hash)
SELECT decode(i, 'hex'), decode(w, 'hex') FROM unnest($1::TEXT[], $2::TEXT[]) as x(i,w)
ON CONFLICT (instance_hash) DO NOTHING
Unfortunately though it's only possible to specify one or two types for the macros to use, an "owned" type and a "borrowed" type. Which ones would be the most useful here? You might think Vec<Vec<u8>> and &[&[u8]] but the latter can only be created by constructing an array or vec of slices which is somewhat redundant.
When the const_panic feature is stabilized we can get rid of the owned/borrowed distinction and just specify a single type and have a const is_compatible() assertion for borrowed types, which would also significantly improve the typechecking code and the errors it gives.
abonander
changed the title
Unsupported type BYTEA[]
Make query!() recognize Vec<Vec<u8>> as a type
Dec 3, 2020
I'm trying to batch a insert of multiple rows with the following query (PostgreSQL):
I'm getting the following error:
unsupported type BYTEA[] for param #1
I'm using the
query!
macro to do it and check the query. Is there a way to do it without doing it unchecked?The text was updated successfully, but these errors were encountered: