Wrong nullable QueryFail
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current behavior
I create Entity and i create a record from Data Grip and when i start nestjs app i have error
Minimum reproduction code
https://github.com/PatrykKuniczak/memesChat/tree/liveChat
Steps to reproduce
npm i npm run start:dev
Expected behavior
Script start, when data in DB is right, compatibile with entity
Package
- I don’t know. Or some 3rd-party package
-
@nestjs/common
-
@nestjs/core
-
@nestjs/microservices
-
@nestjs/platform-express
-
@nestjs/platform-fastify
-
@nestjs/platform-socket.io
-
@nestjs/platform-ws
-
@nestjs/testing
-
@nestjs/websockets
- Other (see below)
Other package
NestJS version
9.0.0
Packages versions
[System Information]
OS Version : Windows 10
NodeJS Version : v16.16.0
NPM Version : 8.1.4
[Nest CLI]
Nest CLI Version : 9.1.5
[Nest Platform Information]
platform-socket.io version : 9.2.1
platform-express version : 9.2.1
mapped-types version : 1.2.0
websockets version : 9.2.1
schematics version : 9.0.3
testing version : 9.2.1
typeorm version : 9.0.1
common version : 9.2.1
config version : 2.2.0
core version : 9.2.1
cli version : 9.1.5
Node.js version
16.16.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
https://github.com/PatrykKuniczak/Machine-Shop-Manager/tree/main/backend
import {Column, Entity, PrimaryGeneratedColumn} from "typeorm";
@Entity('PersonalDatum')
export class PersonalDatum {
@PrimaryGeneratedColumn()
id: number;
@Column({length: 50})
name: string;
@Column({length: 50})
surname: string;
@Column({length: 50})
birthCity: string;
@Column("timestamp with time zone")
birthDate: Date;
}
“QueryFailedError: column “birthDate” of relation “PersonalDatum” contains null values”
I using Postgresql
I have the same issue in my next project
@Entity("User")
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({ length: 20 })
clientId: string;
@Column({ length: 60 , default: ""})
name: string;
}
“QueryFailedError: column “clientId” of relation “User” contains null values”
Whole Error:
QueryFailedError: column "clientId" of relation "User" contains null values
at PostgresQueryRunner.query (F:\Projects\memesChat\backend\src\driver\postgres\PostgresQueryRunner.ts:299:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at PostgresQueryRunner.executeQueries (F:\Projects\memesChat\backend\src\query-runner\BaseQueryRunner.ts:651:13)
at PostgresQueryRunner.addColumn (F:\Projects\memesChat\backend\src\driver\postgres\PostgresQueryRunner.ts:1115:9)
at PostgresQueryRunner.addColumns (F:\Projects\memesChat\backend\src\driver\postgres\PostgresQueryRunner.ts:1129:13)
at RdbmsSchemaBuilder.addNewColumns (F:\Projects\memesChat\backend\src\schema-builder\RdbmsSchemaBuilder.ts:823:13)
at RdbmsSchemaBuilder.executeSchemaSyncOperationsInProperOrder (F:\Projects\memesChat\backend\src\schema-builder\RdbmsSchemaBuilder.ts:226:9)
at RdbmsSchemaBuilder.build (F:\Projects\memesChat\backend\src\schema-builder\RdbmsSchemaBuilder.ts:95:13)
at DataSource.synchronize (F:\Projects\memesChat\backend\src\data-source\DataSource.ts:318:9)
at DataSource.initialize (F:\Projects\memesChat\backend\src\data-source\DataSource.ts:256:43)
^C at DataSource.synchronize (F:\Projects\memesChat\backend\src\data-source\DataSource.ts:318:9)
I’d try do it but still didn’t work:
@Column({ length: 60 , nullable: true})
name?: string;
That’s intresting
create table "User"
(
id serial
constraint "PK_9862f679340fb2388436a5ab3e4"
primary key,
name varchar(60) not null,
"clientId" varchar(20) not null
);
alter table "User"
owner to postgres;
“nullable” work wrong, intresting, that’s something wrong after last update
I set “nullable” to ‘false’ run, and for ‘true’ and DDL looks fine
name varchar(60)
but error appear when i start script
column "clientId" of relation "User" contains null values
I create issue in Typeorm repository, but my bad is I didn’t test it without Nest, yesterday i do it, and it’s work with pure Typeorm, that’s intresting, that’s must be something wrong with 9 version of @nestjs/typeorm. Because earlier i didn’t have error like that
That’s the issue what I’ve told: https://github.com/typeorm/typeorm/issues/9587
I copy and paste, everything but maybe it’s also helpful.
On reproduction code, i send a github with my second project, because it’s less code and relations, easier to test 😃 But my first project is on the first line
I open to send more details 😃
Issue Analytics
- State:
- Created 9 months ago
- Comments:9 (3 by maintainers)
@micalevisk let’s clone now, i done something wrong in code, clone again now 😃
The problem, is “solved” i generate new nestJs app, and copy my src, error didn’t occure anymore.
That’s crazy issue, IDN what’s wrong, computers is a big mistery 😃
Thanks @micalevisk for support 😃