transaction.queryArray(query, args) call signature broken.
KyleJune opened this issue · 1 comments
KyleJune commented
async queryArray<T extends Array<unknown>>(query: string, args?: QueryArguments): Promise<QueryArrayResult<T>>;
When I do the following
transaction.queryArray('INSERT INTO "user" (id, username) VALUES ($1, $2)', [ 0, "user0" ])
I get the following error.
error: TransactionError: The transaction "migrate_apply_0" has been aborted due to `PostgresError: bind message supplies 1 parameters, but prepared statement "" requires 2`. Check the "cause" property to get more details
throw new TransactionError(this.name, e);
^
at Transaction.queryArray (https://deno.land/x/postgres@v0.15.0/query/transaction.ts:417:15)
at async PostgresMigrate._applyQueries (file:///home/kyle/Projects/deno/migrate/postgres.ts:166:11)
at async PostgresMigrate.apply (file:///home/kyle/Projects/deno/migrate/postgres.ts:186:9)
at async assertApplyFirst (file:///home/kyle/Projects/deno/migrate/postgres_test.ts:421:5)
at async file:///home/kyle/Projects/deno/migrate/postgres_test.ts:501:5
at async fn (https://deno.land/x/test_suite@0.9.1/test_suite.ts:469:11)
Caused by: PostgresError: bind message supplies 1 parameters, but prepared statement "" requires 2
at Connection.#preparedQuery (https://deno.land/x/postgres@v0.15.0/connection/connection.ts:858:19)
at async Connection.query (https://deno.land/x/postgres@v0.15.0/connection/connection.ts:930:16)
at async Transaction.queryArray (https://deno.land/x/postgres@v0.15.0/query/transaction.ts:413:14)
at async PostgresMigrate._applyQueries (file:///home/kyle/Projects/deno/migrate/postgres.ts:166:11)
at async PostgresMigrate.apply (file:///home/kyle/Projects/deno/migrate/postgres.ts:186:9)
at async assertApplyFirst (file:///home/kyle/Projects/deno/migrate/postgres_test.ts:421:5)
at async file:///home/kyle/Projects/deno/migrate/postgres_test.ts:501:5
at async fn (https://deno.land/x/test_suite@0.9.1/test_suite.ts:469:11)
The error doesn't occur when using client.queryArray. It appears the issue is that the transaction.queryArray function mistakes it for the template string call signature.
A full example can be found in the following PR.
udibo/migrate#5
My "PostgresMigrate apply apply migration queries" test fails but the equivalent not using a transaction passes.
The one that passes is called "PostgresMigrate apply apply migration queries with disableTransaction".
KyleJune commented
I've verified this is already fixed on main branch.