Skip to content

Array of enums column doesn't work at all #4350

@iFonny

Description

@iFonny

Issue type:

[ ] question
[ x ] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ x ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[ x ] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

Hello!

I have a problem with creating a Column for my ReviewEntity. I want to insert some enums inside an Array. It's working with an enum with only 1 char (like in this example, I have no idea why) but not if I add a value in enum after creation or if I use words.

It's working on the first launch (creation), but If I run again (with sync enabled) I will get an error.

review.entity

  @Column({
    name: 'type',
    type: 'enum',
    enum: ReviewTypeEnum,
    array: true
  })
  type: ReviewTypeEnum[];

review.enums

export enum ReviewTypeEnum {
  Text = 'text',
  Image = 'image',
  Audio = 'audio',
  Video = 'video',
}

Full error:

query failed: ALTER TYPE "public"."_review_types_enum" RENAME TO "review_types_enum_old"
error: { error: cannot alter array type review_types_enum[]
    at Connection.parseE (/Users/ifonny/Travail/Lucette/Lucette-API-nestjs/node_modules/pg/lib/connection.js:602:11)
    at Connection.parseMessage (/Users/ifonny/Travail/Lucette/Lucette-API-nestjs/node_modules/pg/lib/connection.js:399:19)
    at Socket.<anonymous> (/Users/ifonny/Travail/Lucette/Lucette-API-nestjs/node_modules/pg/lib/connection.js:121:22)
    at Socket.emit (events.js:189:13)
    at Socket.EventEmitter.emit (domain.js:441:20)
    at addChunk (_stream_readable.js:284:12)
    at readableAddChunk (_stream_readable.js:265:11)
    at Socket.Readable.push (_stream_readable.js:220:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  name: 'error',
  length: 181,
  severity: 'ERROR',
  code: '42809',
  detail: undefined,
  hint:
   'You can alter type review_types_enum, which will alter the array type as well.',
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'typecmds.c',
  line: '3279',
  routine: 'RenameType' }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions