TypeORM array is not supported in postgres?

ben berizovsky picture ben berizovsky · Aug 22, 2019 · Viewed 12.3k times · Source

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;`

Answer

thopaw picture thopaw · Aug 22, 2019

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[];?