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
CREATETABLEroles (
name varchar(100) NOT NULL,
file_types text[] DEFAULT ARRAY[]::text[] NOT NULL
);
and we want to use unnest to populate the table with data (only one row just for simplicity):
constdata=awaitpool.any(sql.unsafe` INSERT INTO roles (name, file_types) SELECT * FROM ${sql.unnest([['name',['IMAGE']]],['text',sql.fragment`text[]`]// 'text[]' also does not work because it generates $2::"text[]"[])} RETURNING *`);
In this case, the following error is occured:
error: column "file_types" is of type text[] but expression is of type text
Generated sql:
INSERT INTO roles (name, file_types)
SELECT *
FROM unnest($1::"text"[], $2::text[][])
RETURNING *
Generated values:
[[ 'name' ], [ [ 'IMAGE' ] ] ]
P.S. Inserting rows using INSERT INTO roles VALUES (${'name'}, ${sql.array(['IMAGE'], 'text')}) works fine.
The text was updated successfully, but these errors were encountered:
Let's say we have the following table:
and we want to use
unnest
to populate the table with data (only one row just for simplicity):In this case, the following error is occured:
Generated
sql
:Generated
values
:P.S. Inserting rows using
INSERT INTO roles VALUES (${'name'}, ${sql.array(['IMAGE'], 'text')})
works fine.The text was updated successfully, but these errors were encountered: