-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Why are values normalized before "before" lifecycle callbacks #5625
Comments
@Alessy Thanks for posting! We'll take a look as soon as possible. In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly. For help with questions about Sails, click here. |
Hi Alessy, We have facing same issue while upgrading sails 0.12 to 1.0
and remove id field from model attribute. Thanks |
@RavirajKakadeGit Thanks for that! @Alessy Were you able to use this workaround? You might also have greater success (and flexibility) with handling data formatting in your action instead. 👍 |
This workaround doesn't help me. I handle data in action now. Thanks |
@Alessy So besides the workaround, going with an action has helped instead? |
@johnabrams7 Yes, it helped |
Node version: 8.16.0
Sails version (sails): 1.2.1
ORM hook version (sails-hook-orm): 2.1.1
DB adapter & version (sails-mysql): 1.0.1
When creating a record in the database, following code executes
Model.create(initialValues);
Let's say that initialValues object has some additional attributes that Model don't have.
initialValues object is normalized (additional attributes are omitted) before lifecycle callback beforeCreate is called.
In sails v0.12 initialValues object was normalized after beforeCreate lifecycle callback, but in versions after 1.0 this has changed. Why? Now I have problems upgrading my application.
If I set schema: false in config/models.js initialValues object is not normalized. But then I have to omit additional attributes by myself otherwise, the error ER_BAD_FIELD_ERROR happens.
If I want to do this (omit additional attributes) in beforeCreate in config/models.js I can't. because I don't know which specific model is being created, so I don't know which attributes to omit.
Help is needed
The text was updated successfully, but these errors were encountered: