porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.03k stars 255 forks source link

PostgresError: syntax error at or near "$1" #864

Closed josh-i386g closed 1 month ago

josh-i386g commented 1 month ago

im using kysely and kysely-postgres-js

await pgdb.transaction().execute(async (db) => {
  const r1 = await sql`SET LOCAL c.user_id2 TO ${"test"};`.execute(db);
  console.log({ r1 });
});
node:internal/process/esm_loader:46
      internalBinding('errors').triggerUncaughtException(
                                ^

PostgresError: syntax error at or near "$1"
    at ErrorResponse (file://server/node_modules/postgres/src/connection.js:790:26)
    at handle (file://server/node_modules/postgres/src/connection.js:476:6)
    at Socket.data (file://server/node_modules/postgres/src/connection.js:315:9)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:343:12)
    at readableAddChunk (node:internal/streams/readable:316:9)
    at Readable.push (node:internal/streams/readable:253:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42601',
  position: '25',
  file: 'scan.l',
  line: '1241',
  routine: 'scanner_yyerror'
}

Node.js v20.5.1
josh-i386g commented 1 month ago

Solved at https://github.com/porsager/postgres/issues/640#issuecomment-1636850807