We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug When calling em.upsert('Book', { SCODE: 'AGSj', title: ['\\'] }), the command fails.
em.upsert('Book', { SCODE: 'AGSj', title: ['\\'] })
Stack trace
⨯ DriverException: insert into "book" ("scode", "title") values ('AGSj', E'{\\}') on conflict ("scode") do update set "title" = excluded."title" returning "author", "call_number", "discipline", "isbn", "type", "image" - malformed array literal: "{\}" at PostgreSqlExceptionConverter.convertException ([redacted]/node_modules/@mikro-orm/core/platforms/ExceptionConverter.js:8:16) at PostgreSqlExceptionConverter.convertException ([redacted]/node_modules/@mikro-orm/postgresql/PostgreSqlExceptionConverter.js:42:22) at PostgreSqlDriver.convertException (/[redacted]/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:201:54) at [redacted]/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:205:24 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async PostgreSqlDriver.nativeUpdate ([redacted]/node_modules/@mikro-orm/knex/AbstractSqlDriver.js:379:19) at async SqlEntityManager.upsert ([redacted]/node_modules/@mikro-orm/core/EntityManager.js:496:21) at async GET (webpack-internal:///(rsc)/./src/app/api/test/route.ts:16:5) at async [redacted]/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62361 previous error: insert into "book" ("scode", "title") values ('AGSj', E'{\\}') on conflict ("scode") do update set "title" = excluded."title" returning "author", "call_number", "discipline", "isbn", "type", "image" - malformed array literal: "{\}" at Parser.parseErrorMessage ([redacted]/node_modules/pg-protocol/dist/parser.js:287:98) at Parser.handlePacket ([redacted]/node_modules/pg-protocol/dist/parser.js:126:29) at Parser.parse ([redacted]/node_modules/pg-protocol/dist/parser.js:39:38) at Socket.<anonymous> ([redacted]/node_modules/pg-protocol/dist/index.js:11:42) 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) at TCP.callbackTrampoline (node:internal/async_hooks:130:17) { length: 119, severity: 'ERROR', code: '22P02', detail: 'Unexpected end of input.', hint: undefined, position: '56', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'arrayfuncs.c', line: '491', routine: 'ArrayCount' }
To Reproduce Steps to reproduce the behavior:
Expected behavior The upsert should perform without errors.
Additional context
diff --git a/node_modules/@mikro-orm/postgresql/PostgreSqlPlatform.js b/node_modules/@mikro-orm/postgresql/PostgreSqlPlatform.js index 499637a..f8db08d 100644 --- a/node_modules/@mikro-orm/postgresql/PostgreSqlPlatform.js +++ b/node_modules/@mikro-orm/postgresql/PostgreSqlPlatform.js @@ -113,7 +113,7 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform { return true; } marshallArray(values) { - const quote = (v) => v === '' || v.match(/["{},]/) ? JSON.stringify(v) : v; + const quote = (v) => v === '' || v.match(/["{},\\]/) ? JSON.stringify(v) : v; return `{${values.map(v => quote('' + v)).join(',')}}`; } unmarshallArray(value) {
Versions
The text was updated successfully, but these errors were encountered:
Working patch, can make a PR if this looks good:
Sure, as long as it does not break any existing tests, PR welcome! The change is looking good to me.
Sorry, something went wrong.
fix(postgres): escape array literal values containing backslash (#4797)
20179ec
Closes #4796
Successfully merging a pull request may close this issue.
Describe the bug
When calling
em.upsert('Book', { SCODE: 'AGSj', title: ['\\'] })
, the command fails.Stack trace
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The upsert should perform without errors.
Additional context
Versions
The text was updated successfully, but these errors were encountered: