Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To resolve this QueryFailedError in TypeORM and PostgreSQL due to null values in the "price" column, you can use the "default" property in your entity definition.

For example, in your entity definition file, you can set the "default" property for the "price" column to a default value like zero:

import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class Product {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column({ default: 0 })
  price: number;
}

This will ensure that any null values in the "price" column are automatically converted to zero, preventing the QueryFailedError.

You can also use other default values based on your use case, such as an empty string, null, or a specific value that makes sense for your application.