Skip to content

Commit 28f52b1

Browse files
committed
fix isnull lookup
1 parent 09da727 commit 28f52b1

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

.github/workflows/test-python.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ jobs:
7373
defer_regress
7474
from_db_value
7575
lookup.tests.LookupTests.test_escaping
76+
lookup.tests.LookupTests.test_isnull_textfield
77+
lookup.tests.LookupQueryingTests.test_isnull_lookup_in_filter
7678
model_fields
7779
or_lookups
7880
sessions_tests

django_mongodb/query.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,19 +266,7 @@ def _decode_child(self, child):
266266
raise NotSupportedError("Pattern lookups on UUIDField are not supported.")
267267

268268
rhs, rhs_params = child.process_rhs(self.compiler, self.connection)
269-
270269
lookup_type = child.lookup_name
271-
272-
# Since NoSql databases generally don't support aggregation or
273-
# annotation, pass true unless the query has a get_aggregation() method.
274-
# It's a little troubling however that the _nomalize_lookup_value
275-
# method seems to only use this value in the case that the value is an
276-
# iterable and the lookup_type equals isnull.
277-
annotation = (
278-
self.get_aggregation(using=self.connection)[None]
279-
if hasattr(self, "get_aggregation")
280-
else True
281-
)
282270
value = rhs_params
283271
packed = child.lhs.get_group_by_cols()[0]
284272
alias = packed.alias
@@ -299,11 +287,11 @@ def _decode_child(self, child):
299287

300288
field = next(f for f in opts.fields if f.column == column)
301289

302-
value = self._normalize_lookup_value(lookup_type, value, field, annotation)
290+
value = self._normalize_lookup_value(lookup_type, value, field)
303291

304292
return field, lookup_type, value
305293

306-
def _normalize_lookup_value(self, lookup_type, value, field, annotation):
294+
def _normalize_lookup_value(self, lookup_type, value, field):
307295
"""
308296
Undo preparations done by lookups not suitable for MongoDB, and pass
309297
the lookup argument through DatabaseOperations.prep_lookup_value().
@@ -316,7 +304,7 @@ def _normalize_lookup_value(self, lookup_type, value, field, annotation):
316304
"not to be a list. Only 'in'-filters can be used with "
317305
"lists." % lookup_type
318306
)
319-
value = annotation if lookup_type == "isnull" else value[0]
307+
value = value[0]
320308

321309
# Remove percent signs added by PatternLookup.process_rhs() for LIKE
322310
# queries.

0 commit comments

Comments
 (0)