1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #31667 -- Made __in lookup ignore None values.

This commit is contained in:
Adam Johnson
2020-06-05 23:49:08 +01:00
committed by Mariusz Felisiak
parent 36db4dd937
commit 5776a1660e
2 changed files with 31 additions and 3 deletions

View File

@@ -366,10 +366,12 @@ class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
)
if self.rhs_is_direct_value():
# Remove None from the list as NULL is never equal to anything.
try:
rhs = OrderedSet(self.rhs)
rhs.discard(None)
except TypeError: # Unhashable items in self.rhs
rhs = self.rhs
rhs = [r for r in self.rhs if r is not None]
if not rhs:
raise EmptyResultSet