oguimbal / pg-mem

An in memory postgres DB instance for your unit tests
MIT License
1.95k stars 94 forks source link

Integer array items are converted to strings in the resulting sql statement #323

Open stephantromer-pon opened 1 year ago

stephantromer-pon commented 1 year ago

Describe the bug

When saving a column that has the integer array type using TypeORM, the values are converted to strings in the resulting SQL statement.

TypeError: Cannot read properties of null (reading 'map')
at PostgresQueryRunner.query (src/driver/postgres/PostgresQueryRunner.ts:299:19)
    at InsertQueryBuilder.execute (src/query-builder/InsertQueryBuilder.ts:163:33)
    at SubjectExecutor.executeInsertOperations (src/persistence/SubjectExecutor.ts:434:42)
    at SubjectExecutor.execute (src/persistence/SubjectExecutor.ts:137:9)
    at EntityPersistExecutor.execute (src/persistence/EntityPersistExecutor.ts:182:21)

To Reproduce

Entity

@Entity('product')
export class ProductEntity {
  @Column('int', { array: true, nullable: true })
  channels: number[];
}
this.productRepository.save({
  channels: [501]
})

Expected: INSERT INTO "product"("channels") VALUES (ARRAY([501])) Actual INSERT INTO "product"("channels") VALUES (ARRAY(['501']))

pg-mem version

2.6.12