-
-
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
Merge AND conditions into one when chaining scopes #11805
Merge AND conditions into one when chaining scopes #11805
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11805 +/- ##
==========================================
+ Coverage 90.11% 96.25% +6.13%
==========================================
Files 93 95 +2
Lines 9106 9233 +127
==========================================
+ Hits 8206 8887 +681
+ Misses 900 346 -554
Continue to review full report at Codecov.
|
Hello! I see you are a first-time contributor, thank you for taking the time to help Sequelize! I hope to see more PRs from you in the future! I see |
Hello, thanks. |
b567459
to
e69de8e
Compare
Hi @papb basically the PR is ready for review in my opinion but I don't understand why code coverage decreased so much. |
Hello, don't worry about code coverage, it gives some weird results some times... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As is, this PR introduces a breaking change, since what would previously be overwritten now won't. I think this feature should be added in a way that is not a breaking change. I suggest you add a new boolean option to the model definition, called perhaps enableExtendedScopeWhereMerges
, which defaults to false and which you must check for being true
before applying your change.
Also, for a richer feature, in that case you should also enable merging for [Op.or]
and [Op.not]
. What do you think?
Hi @papb I agree about this being a breaking change. I will add the boolean flag as you suggested. It makes sense to me.
In my implementation it merges only |
Actually this is related to #10873, perhaps we can go with merge strategy approach. I think |
I have a problem with this PR. It selectively only merges I am proposing to combine ALL |
The key to understanding why I am proposing this is to realize that
is really shorthand for
|
Hi everyone, the suggestion to merge all WHERE clauses sounds reasonable to me. I'll try to implement it. |
dc7ae80
to
670afed
Compare
Hey guys, just a short update on this PR. |
3041271
to
9641212
Compare
Hi guys. For now I think I've handled most of the cases but still few left. Also need to do some refactoring. |
Thanks for working on this olzv. I'm excited to see the final results. |
7bb3a2a
to
e4cdce9
Compare
e4cdce9
to
c9903ab
Compare
feat(scopes): add expectation on merging scopes defined on field name only feat(scopes): change the resulting merge format for easier handling in merge logic
feat(scopes): because otherwise they were not recognizing symbol keys
feat(scopes): refactor
c9903ab
to
e86d663
Compare
Hi guys, I think it is ready for the review. Please take a look. |
Hey there :) First of all: Thanks a bunch for your contribution to Sequelize! Much appreciated! A couple of months ago, we have switched from master to main branch as our primary development branch and hence this PR is now outdated :( If you still think this change is making sense, please consider recreating the PR against ✌️ |
Closing this since it is still against |
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
Closes #11588
Making it possible to chain scopes without overriding.
For example without this change only the last scope is applied while chaining if they both map condition to
Op.and
operator.