[SOLVED] TypeORM array is not supported in postgres?

Issue

I have a column kid_ages which is Integer[]. When migrating, I get the following error:

DataTypeNotSupportedError: Data type "Array" in "home.kid_ages" is not supported by "postgres" database.

I tried adding the following options to my column:

type: 'array'

and:

array: true,
default: [],
nullable: false,

@Column({
  array: true,
  default: [],
  nullable: false,
})
kid_ages: string;

Solution

The docs says, that it should work:

@Column("int", { array: true })
array: number[];

this is from the example https://github.com/typeorm/typeorm/blob/master/test/functional/database-schema/column-types/postgres/entity/Post.ts

In your code the array property is no array.
Have you tried kid_ages: string[];?

Answered By – thopaw

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *