Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
model.bulkCreate modifies the "options" by assigning "model" as an attribute to the object #12406
Comments
Hey!, It's my first time contributing . I would like to take a stab at this issue. Please correct me if i'm wrong here , in this issue all we need to do is create a copy of Model's object and assign it to |
Nope, I think you need to clone options (just like other implementations in the same file) using Object.assign, This will make sure the passed in object reference is not polluted |
oh yeah, thanks. On it |
Hello, @walkerps are still working on this? |
@JuarezLustosa I went ahead and raised a fix. Do review it |
Issue Description
While using model.bulkCreate, as we pass the options, an object which contains transaction, it comes modified after the execution
What are you doing?
We have called bulkCreate on a model object. The options object which is prepared as an argument to the function, if we check it after execution, it contains the reference to the model object.
Here is the link to the SSCCE for this issue: LINK-HERE
What do you expect to happen?
The options object should not have been modified.
What is actually happening?
The options object now have a reference to "model" object.
Additional context
When we checked the code in sequelize -> model.js, it reflected the assignment on the passed in argument, instead of using the cloned copy of "options"
Environment
Issue Template Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?