You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If one adds a constraint using Check decorator and provides a simple expression, like logical one, and written in lowercase without using parentheses, then migration:create will continue generating the same migration even after migration:up has been applied.
The subsequent migration, however, is not generated if one uses uppercase for sql keywords (for example, IS NOT NULL, OR).
Stack trace
None
To Reproduce
Steps to reproduce the behavior:
Create an entity with two nullable fields
Create a constraint for that entity as:
@Check<EntityTypeHere>({expression: columns=>`${column.<firstColumnNameHere>} is not null or ${column.<secondColumnNameHere>} is not null`,name: '<some_name_here>'})
Generate a migration
Migrate to that migration
Try generating a migration one more time
Expected behavior
No second migration should be created given there were no changes to the entity model.
Observations
It appears if one wraps every expression in parentheses and writes sql keywords in caps, then the issue isn't reproducible.
E.g:
@Check<EntityTypeHere>({expression: columns=>`(${column.<firstColumnNameHere>} IS NOT NULL) OR (${column.<secondColumnNameHere>} IS NOT NULL)`,name: '<some_name_here>',})
Versions
Dependency
Version
node
16.16.0
typescript
4.8.4
mikro-orm
5.5.3
your-driver
postgresql (5.5.3)
The text was updated successfully, but these errors were encountered:
Interesting, I guess postgres normalizes the query and store that instead of the expression provided by you. Will try to find some way to get around this, worst case we could compare the expression as lower case and ignore parens, could be good enough heuristic about what changed.
Describe the bug
If one adds a constraint using Check decorator and provides a simple expression, like logical one, and written in lowercase without using parentheses, then
migration:create
will continue generating the same migration even aftermigration:up
has been applied.The subsequent migration, however, is not generated if one uses uppercase for
sql
keywords (for example,IS NOT NULL
,OR
).Stack trace
None
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No second migration should be created given there were no changes to the entity model.
Observations
It appears if one wraps every expression in parentheses and writes
sql
keywords in caps, then the issue isn't reproducible.E.g:
Versions
The text was updated successfully, but these errors were encountered: