-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Fixed #20024 -- Corrected handling of __in lookups with None in exclude querysets to match SQL semantics. #20027
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
base: main
Are you sure you want to change the base?
Conversation
… exclude querysets to match SQL semantics.
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.
Thanks for the PR!
@charettes reviewed #19691, so he might have some thoughts.
| # into subquery above | ||
| self.assertIs(inner_qs._result_cache, None) | ||
|
|
||
| @unittest.expectedFailure |
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.
There were some tests included with #19691 we should add.
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.
The composite pk one seems valuable, not sure about the other one though 🤔
| clause.add(lookup_class(col, False), AND) | ||
| if ( | ||
| lookup_type == "in" | ||
| and isinstance(condition.rhs, (list, tuple)) |
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.
This should accept any iterable.
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.
It's unfortunate that we have to hardcode this logic here but hopefully #16817 would allow us to revisit this properly by having lookups.In.exclude_nulls return the proper constraint.
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.
Looks like the right approach to me!
| clause.add(lookup_class(col, False), AND) | ||
| if ( | ||
| lookup_type == "in" | ||
| and isinstance(condition.rhs, (list, tuple)) |
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.
It's unfortunate that we have to hardcode this logic here but hopefully #16817 would allow us to revisit this properly by having lookups.In.exclude_nulls return the proper constraint.
| # into subquery above | ||
| self.assertIs(inner_qs._result_cache, None) | ||
|
|
||
| @unittest.expectedFailure |
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.
The composite pk one seems valuable, not sure about the other one though 🤔
Trac ticket number
ticket-20024
Branch description
Problem
The SQL generated by an exclude queryset is not semantically aligned with the queryset when using
__inlookups containingNone.Solution
The PR updates
WhereNodeto useORand generateIS NULLfor correct SQL semantics in this case.Checklist
mainbranch.