-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Problem comparing json default value in postgresql migrations #4212
Comments
|
Maybe the diffing does not work correctly for JSON type, it's a bit tricky - there are some changes in master that should help with that. Could you try latest dev version and drop the Or try using |
The development version, unfortunately, does not solve the problem. We anyway cannot pass the object to Currently, we are converting the object to a For my specific case, the ideal approach would be to generate default values based on a deep comparison of both objects. Perhaps something like this can be made here, i guess Something like this check: if (to.mappedType instanceof JsonType && from.default && to.default) {
// remove single quotes from the start and end of default json
const normalize = (str: string) => str.replace(/(^'|'$)/g, '');
const defaultValueFrom = parseJsonSafe(normalize(from.default));
const defaultValueTo = parseJsonSafe(normalize(to.default));
return Utils.equals(defaultValueTo, defaultValueFrom);
} The problem may be much more complex. Unfortunately, I am not familiar with the codebase. |
Defaults are compared via Once this is fixed, you will most probably need to drop that |
There is similar issue when persisting entities. Example: Mikro-ORM loads entity list via |
Try latest dev version, that should be now working correctly. |
Describe the bug
After we created the initial migration for the model with a JSON field that has a default value, all next migrations will attempt to modify the default value to the same one.
To Reproduce
https://github.com/DeityLamb/mikro-orm-issue
Create an entity that has a json field with default value
mikro-orm migration:create # created first migration
mikro-orm migration:up # we up migration and not to change anything
mikro-orm migration:create # a new migration was created that changes the default value to the same
Expected behavior
Do not include changes to default values in migration if they have not been modified.
Versions
Quick inspection
Entity
Initial migration
All subsequent migrations will include this even if the default value has not been changed.
The text was updated successfully, but these errors were encountered: