diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 3903b3c0..7a70d258 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -73,6 +73,8 @@ jobs: defer_regress from_db_value lookup.tests.LookupTests.test_escaping + lookup.tests.LookupTests.test_isnull_textfield + lookup.tests.LookupQueryingTests.test_isnull_lookup_in_filter model_fields or_lookups sessions_tests diff --git a/django_mongodb/query.py b/django_mongodb/query.py index b5354bb8..b5d51e3d 100644 --- a/django_mongodb/query.py +++ b/django_mongodb/query.py @@ -266,19 +266,7 @@ def _decode_child(self, child): raise NotSupportedError("Pattern lookups on UUIDField are not supported.") rhs, rhs_params = child.process_rhs(self.compiler, self.connection) - lookup_type = child.lookup_name - - # Since NoSql databases generally don't support aggregation or - # annotation, pass true unless the query has a get_aggregation() method. - # It's a little troubling however that the _nomalize_lookup_value - # method seems to only use this value in the case that the value is an - # iterable and the lookup_type equals isnull. - annotation = ( - self.get_aggregation(using=self.connection)[None] - if hasattr(self, "get_aggregation") - else True - ) value = rhs_params packed = child.lhs.get_group_by_cols()[0] alias = packed.alias @@ -299,11 +287,11 @@ def _decode_child(self, child): field = next(f for f in opts.fields if f.column == column) - value = self._normalize_lookup_value(lookup_type, value, field, annotation) + value = self._normalize_lookup_value(lookup_type, value, field) return field, lookup_type, value - def _normalize_lookup_value(self, lookup_type, value, field, annotation): + def _normalize_lookup_value(self, lookup_type, value, field): """ Undo preparations done by lookups not suitable for MongoDB, and pass the lookup argument through DatabaseOperations.prep_lookup_value(). @@ -316,7 +304,7 @@ def _normalize_lookup_value(self, lookup_type, value, field, annotation): "not to be a list. Only 'in'-filters can be used with " "lists." % lookup_type ) - value = annotation if lookup_type == "isnull" else value[0] + value = value[0] # Remove percent signs added by PatternLookup.process_rhs() for LIKE # queries.