-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
bulkCreate updateOnDuplicate createdAt
field explicitly omitted
#17347
Comments
Looking to get feedback / approval for this bug before I put time into it. |
createdAt
field explicitly omitted
I did some digging and found that the Line 2706 in 6aba382
This change was introduced with commit 0ce88c4. Initially |
…#updateOnDuplicate` Fixes issue sequelize#17347
I came to realize that timestamps have a few more special cases, i.e. one can also not simply "touch" an instance via Lines 3343 to 3347 in b9e71a7
I think we should honor the users request to update timestamps when explicitly asked to do so rather than silently omitting the update. I'd be willing to implement the required changes if the maintainers concur with this sentiment. As a workaround one can disable the timestamps and explicitly specify and configure / augment the fields in the model definition. |
Issue Creation Checklist
Bug Description
When using
bulkCreate
to create records but wanting to update automatic keys (like the timestamps) on duplicates, an invalid query is generated.Reproducible Example
Here is the link to the SSCCE for this issue:
https://github.com/sequelize/sequelize-sscce/pull/277/files
https://github.com/LJ1102/sequelize-sscce/tree/main
What do you expect to happen?
Create row with given id or update
createdAt
timestamp of instance matching the id.What is actually happening?
Generates a broken query:
Environment
Would you be willing to resolve this issue by submitting a Pull Request?
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as " 1" will be removed.
The text was updated successfully, but these errors were encountered: