Skip to content

ENUM error : synchroize doesn't check if enumtype already exists in postgres #5738

@jeromeSH26

Description

@jeromeSH26

[ ] bug report
[ ] postgres

when synchronise is on, typeorm doesn't check if a enum type already exists when using "enumName" .

I guess a IF NO EXISTS is missing somewhere


	@Column({
		type: "enum",
		nullable: false,
		enum: ECountry,
		enumName: "ecountry",
		default: ECountry.TODEFINED,
	})
	countryBudget: ECountry;

error is the following (type already exists)

query failed: CREATE TYPE "ecountry" AS ENUM('FR', 'GR', 'TODEFINED')
error: error: le type « ecountry » existe déjà
    at Connection.parseE (C:\Users\asterix\dev\DWP_BUDGET\node_modules\pg\lib\connection.js:614:13)
    at Connection.parseMessage (C:\Users\asterix\dev\DWP_BUDGET\node_modules\pg\lib\connection.js:413:19)
    at Socket.<anonymous> (C:\Users\asterix\dev\DWP_BUDGET\node_modules\pg\lib\connection.js:129:22)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:273:9)
    at Socket.Readable.push (_stream_readable.js:214:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
  name: 'error',
  length: 157,
  severity: 'ERREUR',
  code: '42710',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'd:\\pginstaller.auto\\postgres.windows-x64\\src\\backend\\commands\\typecmds.c',
  line: '1186',
  routine: 'DefineEnum'
}

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