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
Sequelize getter produce invalid/repeating query when given an options object #2311
Comments
When the where object is empty / has an unexpected structure it defaults to 1=1 which is always true. It seems the options are added into the object. Ideally we should of course be cloning it each time but it's a question of performance vs being able to reuse the the object |
Which version? |
Current master |
Changing given objects from the user can produce so many side effects and is really frustrating. |
@janmeier we should already be cloning options on all find calls and i think all association getters use find internally now. Edit: But looking at the SQL we might not be. In any case the performance overhead of cloning on getters is negligible, they are not an often called method in the execution change of fetching something. |
@mickhansen I though the same, but the problem is that the getter adds an and. https://github.com/sequelize/sequelize/blob/master/lib/associations/has-many-double-linked.js#L28-L32 Since the options.where is empty it resolves to 1=1, and does so every time :). |
@janmeier the |
Yep, each call does a |
@janmeier oh right, yea so we need to clone it in the getter. |
Closed in d3bf724 |
Generated sql:
It seems query information is attached to the options object you can repeat the get calls to make the SELECT query as long as you want.
Example with 3
getBs(options)
calls:And what does the
1=1
do?The text was updated successfully, but these errors were encountered: