Open VxRain opened 6 months ago
I can replicate this but it manifests in a slightly different way. When I am trying to insert a object as JSON, the automatic string conversion fails when object contains a type
field instead creating the string [Object object]
vs the expected JSON string:
column "content" is of type json but expression is of type text, PostgresError, ERROR, ERROR, 42804, You will need to rewrite or cast the expression., 127, parse_target.c, 31, 10, 586, 10, /app/node_modules/postgres/src/errors.js, transformAssignedExpr, INSERT INTO logs ("id","actor_id","created_at","type","content","confirmed_at","collection_reference_id") VALUES ($1,$2,$3,$4,$5,$6,$7), 018fc991-4721-72f1-b58d-633942a9125d,user_01HRTCRHP9VX4B4TF0PN6TT3CR,1717073692449,collection.update,[object Object],1717073692721,018fb014-7b64-7a7e-89f9-941831e80310, [object Object],[object Object], 2950,25,20,25,25,20,2950
The architecture is a fully event based system were payloads are sent in a wrapper, the payloads which do not have type
in the content field work fine.
You can use sql.json helper to correctly serialize the value
Hi, everyone,I encountered a strange phenomenon: if the array object contains the key "type", an error occurs during insertion.
Reproduction Code
Env
Nodejs: v20.11.1 Postgres.js: 3.4.4 PostgreSQL: 15.3