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
my program is getting multiple rows from another query:
for await (const rows of sql`SELECT <...some-query...>`.cursor(10) {
// some checking/processing of the rows data,
// then insert to another table, with
await sql`INSERT <...another-table> ${sql(rows)}`
}
it turns:
ERROR: 42601 PostgresError: syntax error at or near ""0""
in debugging logs:
INSERT INTO <...another-table> "0"=$1,"1"=$2,"2"=$3
with parameters:
params: [
{ ... }, { ... }, { ... }
]
in this cases rows is a query result Array of 3 elements, but it seems sql(rows) did not recognize it as array of multiple inserts, but consider it as a single object insert instead, and derived 3 keys as 01 and 2
the same code of multiple inserts seems working before, but not sure what changes triggered it, and when it happens, what can i do,
// notice here when the problem happens, the `params` is passed with each raw objects in,
but when the same multiple inserts works before, all objects' values were flattened to pass in values
that porsager/postgres#concurrent-cursors looks like correct: generated correct sql with all column values as primitives ($1,$2,$3,...) passed as bind parameters
'INSERT INTO schema1.table ("id","column1","...")values($1,$2,$3,$4,$5,$6),($7,$8,$9,$10,$11,$12),($13,$14,$15,$16,$17,$18)\n'
my program is getting multiple rows from another query:
it turns:
in debugging logs:
with parameters:
in this cases
rows
is a query result Array of 3 elements, but it seemssql(rows)
did not recognize it as array of multiple inserts, but consider it as a single object insert instead, and derived 3 keys as0
1
and2
the same code of multiple inserts seems working before, but not sure what changes triggered it, and when it happens, what can i do,
but when the same multiple inserts works before, all objects' values were flattened to pass in values
what's the problem here, how can I tell
sql(rows)
is a real array of objects instead of single insert object?The text was updated successfully, but these errors were encountered: