Skip to content

Commit 953e4fc

Browse files
committed
edits
1 parent d1d9c33 commit 953e4fc

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

django_mongodb/compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ def collection_name(self):
442442
if isinstance(v, BaseTable) and self.query.alias_refcount[k]
443443
)
444444
except StopIteration:
445+
# Use a dummy collection if the query doesn't specify a table
446+
# (such as Constraint.validate() with a condition).
445447
query = self.query_class(self)
446448
query.aggregation_pipeline = [{"$facet": {"__null": []}}]
447449
self.subqueries.insert(0, query)

django_mongodb/features.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
2323
supports_expression_indexes = False
2424
supports_foreign_keys = False
2525
supports_ignore_conflicts = False
26+
# Before MongoDB 6.0, $in cannot be used in partialFilterExpression.
2627
supports_in_index_operator = property(operator.attrgetter("is_mongodb_6_0"))
2728
supports_json_field_contains = False
2829
# BSON Date type doesn't support microsecond precision.
@@ -97,7 +98,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
9798
"expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor_right_null",
9899
"expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or",
99100
}
100-
# Before MongoDB 6.0, $in cannot be used in partialFilterExpression.
101101
_django_test_expected_failures_partial_expression_in = {
102102
"schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index",
103103
}
@@ -106,7 +106,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
106106
def django_test_expected_failures(self):
107107
expected_failures = super().django_test_expected_failures
108108
expected_failures.update(self._django_test_expected_failures)
109-
if not self.is_mongodb_6_0:
109+
if not self.supports_in_index_operator:
110110
expected_failures.update(self._django_test_expected_failures_partial_expression_in)
111111
if not self.is_mongodb_6_3:
112112
expected_failures.update(self._django_test_expected_failures_bitwise)

django_mongodb/indexes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from .query_utils import process_rhs
1111

12-
mongo_operators_idx = {
12+
MONGO_INDEX_OPERATORS = {
1313
"exact": "$eq",
1414
"gt": "$gt",
1515
"gte": "$gte",
@@ -33,7 +33,7 @@ def builtin_lookup_idx(self, compiler, connection):
3333
lhs_mql = self.lhs.target.column
3434
value = process_rhs(self, compiler, connection)
3535
try:
36-
operator = mongo_operators_idx[self.lookup_name]
36+
operator = MONGO_INDEX_OPERATORS[self.lookup_name]
3737
except KeyError:
3838
raise NotSupportedError(
3939
f"MongoDB does not support the '{self.lookup_name}' lookup in indexes."

django_mongodb/lookups.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ def is_null(self, compiler, connection):
5151
if not isinstance(self.rhs, bool):
5252
raise ValueError("The QuerySet value for an isnull lookup must be True or False.")
5353
if isinstance(self.lhs, Value):
54-
if self.lhs.value is None or (
55-
self.lhs.value == "" and connection.features.interprets_empty_strings_as_nulls
56-
):
54+
if self.lhs.value is None:
5755
result_exception = FullResultSet if self.rhs else EmptyResultSet
5856
else:
5957
result_exception = EmptyResultSet if self.rhs else FullResultSet
File renamed without changes.

0 commit comments

Comments
 (0)