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
mikro-orm migration: create command generates incorrect SQL : 'create table "user" ("id" jsonb not null, "created_at" jsonb not null, "updated_at" jsonb not null);'
So when I want to insert a User, I get this stack trace because the js/ts object has a key 'created_at' which is a date, instead
a 'jsonb' as SQL expected (because 'jsonb' is the wrong SQL type generated).
[info] MikroORM successfully connected to database db on postgresql://db_user:*****@localhost:5432
[query] begin
[query] insert into "user" ("created_at", "id", "updated_at") values ('2020-11-04T15:38:12.147Z', '0f060e86-6447-4e76-ba36-fd1c3bf1d3ba', '2020-11-04T15:38:12.147Z') returning "id" [took 1 ms]
[query] rollback
DriverException: insert into "user" ("created_at", "id", "updated_at") values ('2020-11-04T15:38:12.147Z', '0f060e86-6447-4e76-ba36-fd1c3bf1d3ba', '2020-11-04T15:38:12.147Z') returning "id" - invalid input syntax for type json
at PostgreSqlExceptionConverter.convertException (/home/foobar/mikro-orm-issue/node_modules/@mikro-orm/core/platforms/ExceptionConverter.js:8:16)
at PostgreSqlExceptionConverter.convertException (/home/foobar/mikro-orm-issue/node_modules/@mikro-orm/postgresql/PostgreSqlExceptionConverter.js:40:22)
at PostgreSqlDriver.convertException (/home/foobar/mikro-orm-issue/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:168:54)
at /home/foobar/mikro-orm-issue/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:172:24
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async PostgreSqlDriver.nativeInsert (/home/foobar/mikro-orm-issue/node_modules/@mikro-orm/knex/AbstractSqlDriver.js:145:21)
at async ChangeSetPersister.persistNewEntity (/home/foobar/mikro-orm-issue/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:55:21)
at async ChangeSetPersister.executeInserts (/home/foobar/mikro-orm-issue/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:24:13)
at async UnitOfWork.commitCreateChangeSets (/home/foobar/mikro-orm-issue/node_modules/@mikro-orm/core/unit-of-work/UnitOfWork.js:455:9)
at async UnitOfWork.persistToDatabase (/home/foobar/mikro-orm-issue/node_modules/@mikro-orm/core/unit-of-work/UnitOfWork.js:417:13)
Here is the docker container postgres logs :
2020-11-04 15:33:51.645 UTC [72] ERROR: invalid input syntax for type json at character 63
2020-11-04 15:33:51.645 UTC [72] DETAIL: Expected end of input, but found "-11".
2020-11-04 15:33:51.645 UTC [72] CONTEXT: JSON data, line 1: 2020-11...
2020-11-04 15:33:51.645 UTC [72] STATEMENT: insert into "user" ("created_at", "id", "updated_at") values ('2020-11-04T15:33:51.514Z', '87c82e5f-b7f3-4fd5-ad4b-90adeec4e77e', '2020-11-04T15:33:51.514Z') returning "id"
and finally the real bug is when node dist/main.js
Expected behavior
When mikro-orm was in version 3.6.15, the command generated:
'create table "user" ("id" varchar(255) not null, "created_at" timestamptz(0) not null, "updated_at" timestamptz(0) not null);'
It expected to generate same SQL in 4.2.3 i think.
Versions
Dependency
Version
node
12.19.0
typescript
4.0.5
mikro-orm
4.2.4
your-driver
postgresql
The text was updated successfully, but these errors were encountered:
Describe the bug
mikro-orm migration: create
command generates incorrect SQL :'create table "user" ("id" jsonb not null, "created_at" jsonb not null, "updated_at" jsonb not null);'
So when I want to insert a User, I get this stack trace because the js/ts object has a key 'created_at' which is a date, instead
a 'jsonb' as SQL expected (because 'jsonb' is the wrong SQL type generated).
Here is the docker container postgres logs :
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/pacome35220/mikro-orm-issue
cd mikro-orm-issue
npm install
tsc
docker run --rm -e 'POSTGRES_USER=db_user' -e 'POSTGRES_PASSWORD=db_password' -e 'POSTGRES_DB=db' -p 5432:5432 postgres
mikro-orm migration:create
look the file in
./migrations/
, the SQL is wrongNext you can run
mikro-orm migration:up
and finally the real bug is when
node dist/main.js
Expected behavior
When mikro-orm was in version 3.6.15, the command generated:
'create table "user" ("id" varchar(255) not null, "created_at" timestamptz(0) not null, "updated_at" timestamptz(0) not null);'
It expected to generate same SQL in 4.2.3 i think.
Versions
The text was updated successfully, but these errors were encountered: