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
"insert into \"service_person\" (\"id\", \"service_area\") values ('21a101b6-cae5-4094-bbf7-5a19eef37d7f', '{[object Object],[object Object]}') returning \"id\", \"service_area\" - invalid input syntax for type json"
No TS warnings whatsoever, if I make a breakpoint just before flushing and inspect theservicePerson entity I see the correct array with correct objects.
Stack trace
{"type":"DriverException","message":"insert into "service_person" ("id", "service_area") values ('21a101b6-cae5-4094-bbf7-5a19eef37d7f', '{[object Object],[object Object]}') returning "id", "service_area" - invalid input syntax for type json" - invalid input syntax for type json","stack":"DriverException: insert into "service_person" ("id", "service_area") values ('21a101b6-cae5-4094-bbf7-5a19eef37d7f', '{[object Object],[object Object]}') returning "id", "service_area - invalid input syntax for type json
at PostgreSqlExceptionConverter.convertException (/path/to/my/project/node_modules/@mikro-orm/core/platforms/ExceptionConverter.js:8:16)
at PostgreSqlExceptionConverter.convertException (/path/to/my/project/node_modules/@mikro-orm/postgresql/PostgreSqlExceptionConverter.js:42:22)
at PostgreSqlDriver.convertException (/path/to/my/project/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:197:54)
at /path/to/my/project/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:201:24
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PostgreSqlDriver.nativeInsertMany (/path/to/my/project/node_modules/@mikro-orm/knex/AbstractSqlDriver.js:303:21)
at async ChangeSetPersister.persistNewEntity (/path/to/my/project/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:85:21)
at async ChangeSetPersister.executeInserts (/path/to/my/project/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:29:13)
at async ChangeSetPersister.runForEachSchema (/path/to/my/project/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:68:13)
at async UnitOfWork.commitCreateChangeSets (/path/to/my/project/node_modules/@mikro-orm/core/unit-of-work/UnitOfWork.js:739:9)
Expected behavior
I'd expect this array to be saved into the DB with no errors
Additional context
I'm a noob. Please point me into the relevant doc if I missed one - seen this, but couldn't find the answer there
Versions
Dependency
Version
node
18.12.1
typescript
5.0.4
mikro-orm
5.7.12
your-driver
Postgres
The text was updated successfully, but these errors were encountered:
Looks like the detection of JSON types based on columnType is not working properly.
You should be doing this instead, as JSONb is the default mapping for JSON columns in postgres, no need to specify that via columnType. By using type you will also set the JsonType to that property which handles the conversion.
Describe the bug
I'm trying to store an array of objects inside a
jsonb
column in Postgres.My model is defined like this:
When I run
I get the following error:
No TS warnings whatsoever, if I make a breakpoint just before flushing and inspect the
servicePerson
entity I see the correct array with correct objects.Stack trace
Expected behavior
I'd expect this array to be saved into the DB with no errors
Additional context
I'm a noob. Please point me into the relevant doc if I missed one - seen this, but couldn't find the answer there
Versions
The text was updated successfully, but these errors were encountered: