Skip to content

Enum string not escaping resulting in broken migrations. #4630

@duckies

Description

@duckies

Issue type:

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

Database system/driver:

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

TypeORM version:

[*] latest (0.2.18 for reference)
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

I am encountering an odd issue where providing an enum of strings with an apostrophe in it is not being escaped, so the SQL fails. A small repository that demonstrates the issue along with the full error is here.

export enum Realm {
  Nerzhul = "Ner'zhul",
}

@Entity("character")
export class Character {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: "enum", enum: Realm })
  realm: Realm;
}

Produces the following incorrect query string for the realm column type:
CREATE TYPE "character_realm_enum" AS ENUM('Ner'zhul')

Trying to format the enum differently or escape it in the code did not help, Typeorm always generated incorrect migrations. I also don't know how to stop Typeorm from trying to create migrations for this field. Any help is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions