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 am experiencing an issue where it is not possible to create queries with an argument that takes an array of items. The documentation provides the following examples for creating such queries:
-- name: ListAuthorsByIDs :manySELECT*FROM authors
WHERE id IN (sqlc.slice('ids'));
-- name: ListAuthorsByIDs :manySELECT*FROM authors
WHERE id = ANY($1::int[]);
However, these methods do not generate the expected TypeScript types for the input arguments.
Using ANY($1::int[]) results in a missing identifier.
{
: number[];
}
Using sqlc.slice('ids') results in the type not being identified as an array.
{
ids: string;
}
Steps to Reproduce
The steps are for postgresql, but the issue seems to be the same for all SQL dialects.
Add the examples from the documentation to the examples/authors/postgresql/query.sql
Run sql generate from examples directory.
Observe the output in examples/node-postgres/sql/db/query_sql.ts
The text was updated successfully, but these errors were encountered:
ex-nihil
changed the title
Inability to Create Queries with Array Arguments
Inability to create queries with Array arguments
Jun 18, 2024
I am experiencing an issue where it is not possible to create queries with an argument that takes an array of items. The documentation provides the following examples for creating such queries:
However, these methods do not generate the expected TypeScript types for the input arguments.
Using
ANY($1::int[])
results in a missing identifier.Using
sqlc.slice('ids')
results in the type not being identified as an array.Steps to Reproduce
The steps are for postgresql, but the issue seems to be the same for all SQL dialects.
examples/authors/postgresql/query.sql
sql generate
fromexamples
directory.examples/node-postgres/sql/db/query_sql.ts
The text was updated successfully, but these errors were encountered: