Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comma in check constraint value causes error with cli command schema:drop with Postgres #3460

Closed
jvdberg08 opened this issue Sep 5, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@jvdberg08
Copy link

Describe the bug
A clear and concise description of what the bug is.

When you have a check constraint with a value with a comma in it, trying to drop the schema through the CLI.
This happens due to the m2[1].split(',') here: https://github.com/mikro-orm/mikro-orm/blob/master/packages/postgresql/src/PostgreSqlSchemaHelper.ts#L150

Stack trace

TypeError: Cannot read properties of null (reading '1')
    at /home/jvdberg08/work/scopio/node_modules/@mikro-orm/postgresql/PostgreSqlSchemaHelper.js:125:59
    at Array.map (<anonymous>)
    at /home/jvdberg08/work/scopio/node_modules/@mikro-orm/postgresql/PostgreSqlSchemaHelper.js:123:55
    at Array.reduce (<anonymous>)
    at PostgreSqlSchemaHelper.getEnumDefinitions (/home/jvdberg08/work/scopio/node_modules/@mikro-orm/postgresql/PostgreSqlSchemaHelper.js:113:30)
    at Function.create (/home/jvdberg08/work/scopio/node_modules/@mikro-orm/knex/schema/DatabaseSchema.js:57:60)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SchemaGenerator.getDropSchemaSQL (/home/jvdberg08/work/scopio/node_modules/@mikro-orm/knex/schema/SchemaGenerator.js:99:24)
    at async SchemaGenerator.dropSchema (/home/jvdberg08/work/scopio/node_modules/@mikro-orm/knex/schema/SchemaGenerator.js:73:21)
    at async Function.handleSchemaCommand (/home/jvdberg08/work/scopio/node_modules/@mikro-orm/cli/commands/SchemaCommandFactory.js:86:13)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

To Reproduce
Steps to reproduce the behavior:

  1. Add an enum to an entity defined as export enum X { AB = 'A,B' }
  2. Run migrations
  3. yarn mikro-orm schema:drop -r throws an error.

Expected behavior
No error 😛

Additional context
Add any other context about the problem here.

Versions

Dependency Version
node 16.13.0
typescript 4.7.2
mikro-orm 5.2.3
postgresql 5.2.3
@B4nan B4nan added the bug Something isn't working label Sep 6, 2022
@B4nan B4nan closed this as completed in c8062cb Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants