How I fixed QueryFailedError: column "<columnName>" contains null values in TypeORM?


nestjs typeorm nodejs

I got this error in my NestJS app:

[Nest] 34133  - 02/04/2022, 14:23:30   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (4)...
QueryFailedError: column "<columnName>" contains null values

The following field in API produced this error, probably its related to TypeORM module:

someField: any | null

I fixed this error by configuring the @Column decorator. I have enabled the nullable flag for it:

  @ApiProperty({ description: 'The id of the connected Model' })
  @IsDefined()
  @Column({type: 'json', nullable: true})
  someField: any;
comments powered by Disqus