-
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
Waterline createEach() modify the input array #6862
Comments
@lucafaggianelli 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, @lucafaggianelli! This is expected behavior as of Sails v1, but I'm not seeing that it's explicitly stated outside of the upgrade guide. We'll have to make this aspect of Regarding your issue, we recommend either cloning an array before passing it into Thanks for bringing this to our attention! |
OK good to know! So just for clarification, the mutation of the argument happens on all CRUD methods, that is, |
It is true that criteria passed into any Waterline model method is now mutated, but it is also true that the default behavior of the methods Here's the Waterline section of the upgrade guide that talks about this |
Fascinating. mongodb v3.6 Mutated inputs from a create(input) and createEach(inputs) include the created record's ID(s), so technically a fetch() on createEach() isn't needed if you are only interested in grabbing the IDs. I wouldn't recommend as I suspect this undocumented feature or bug, however you perceive it, may magically "go away" in a future release. |
Node version: 10.16.3
Sails version (sails): 1.2.3
ORM hook version (sails-hook-orm): 2.1.1
Sockets hook version (sails-hook-sockets): 1.5.5
Organics hook version (sails-hook-organics): 1.0.0
Grunt hook version (sails-hook-grunt): 4.0.1
Uploads hook version (sails-hook-uploads): 0.4.3
DB adapter & version (e.g. sails-mysql@5.55.5): sails-mysql@1.0.1
Skipper adapter & version (e.g. skipper-s3@5.55.5): none
I don't know if it's the intended behavior, but for sure is very strange and not documented:
Basically the input array has been modified by createEach. The docs say that the function doesn't return the created record but doesn't talk about preserving the array
The text was updated successfully, but these errors were encountered: