-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
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
0.3.1: Cannot update JSONB array fields, invalid input syntax #8772
Comments
you must add |
I see.. it seems like I also need to update the default value now, instead of string, to just the normal empty array, the default value in postgres does seem to put it as an object though query: ALTER TABLE "group" DROP COLUMN "newestMessageSeenUserIds"
query: ALTER TABLE "group" ADD "newestMessageSeenUserIds" jsonb array NOT NULL DEFAULT '{}' It still does give me the exact same update statement though and invalid input syntax, query: UPDATE "group" SET "newestMessageSeenUserIds" = $1, "updatedAt" = CURRENT_TIMESTAMP WHERE "id" IN ($2) -- PARAMETERS: [["a31c0021-c851-480a-ba9c-a8ada4d31d70"],"c14ccd9e-5c0e-48ee-ab7b-57b224e60af4"]
query failed: UPDATE "group" SET "newestMessageSeenUserIds" = $1, "updatedAt" = CURRENT_TIMESTAMP WHERE "id" IN ($2) -- PARAMETERS: [["a31c0021-c851-480a-ba9c-a8ada4d31d70"],"c14ccd9e-5c0e-48ee-ab7b-57b224e60af4"]
error: error: invalid input syntax for type json
at Parser.parseErrorMessage (/Users/jimmychen/Desktop/Actually_Uni/Programmin/Software/React/Demos/Esposter-backend/node_modules/pg-protocol/src/parser.ts:369:69)
at Parser.handlePacket (/Users/jimmychen/Desktop/Actually_Uni/Programmin/Software/React/Demos/Esposter-backend/node_modules/pg-protocol/src/parser.ts:188:21)
at Parser.parse (/Users/jimmychen/Desktop/Actually_Uni/Programmin/Software/React/Demos/Esposter-backend/node_modules/pg-protocol/src/parser.ts:103:30)
at Socket.<anonymous> (/Users/jimmychen/Desktop/Actually_Uni/Programmin/Software/React/Demos/Esposter-backend/node_modules/pg-protocol/src/index.ts:7:48)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:199:23) {
length: 162,
severity: 'ERROR',
code: '22P02',
detail: 'Token "a31c0021" is invalid.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: 'JSON data, line 1: a31c0021...',
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'jsonfuncs.c',
line: '621',
routine: 'json_ereport_error'
} Do we have a new syntax for updating jsonb array values? Typescript does not complain to me if I do this even though it doesn't work
|
I'll release a fix in |
@pleerock Sweet, confirmed fix on |
@pleerock , Unfortunately, this still does not work for me. My field is mapped as:
I get the error: I am using
|
Issue Description
I have a jsonb string array
And I update it like this
But in 0.3.1 it does not work anymore and gives me this stack trace, which seems to indicate that this is not transforming the parameters into the correct values anymore
Expected Behavior
String array should be appended with newest value in database
Actual Behavior
Raises input syntax error
My Environment
Additional Context
Relevant Database Driver(s)
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: