Skip to content

Commit

Permalink
make QuerySet.exclude() range lookup exclude data with a null boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
WaVEV authored Oct 3, 2024
1 parent fba8892 commit 5c29684
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion django_mongodb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ def _isnull_operator(a, b):
"lte": lambda a, b: {"$lte": [a, b]},
"in": lambda a, b: {"$in": [a, b]},
"isnull": _isnull_operator,
"range": lambda a, b: {"$and": [{"$gte": [a, b[0]]}, {"$lte": [a, b[1]]}]},
"range": lambda a, b: {
"$and": [
{"$or": [DatabaseWrapper._isnull_operator(b[0], True), {"$gte": [a, b[0]]}]},
{"$or": [DatabaseWrapper._isnull_operator(b[1], True), {"$lte": [a, b[1]]}]},
]
},
"iexact": lambda a, b: regex_match(a, ("^", b, {"$literal": "$"}), insensitive=True),
"startswith": lambda a, b: regex_match(a, ("^", b)),
"istartswith": lambda a, b: regex_match(a, ("^", b), insensitive=True),
Expand Down
2 changes: 0 additions & 2 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests.test_trunc_timezone_applied_before_truncation",
# Length of null considered zero rather than null.
"db_functions.text.test_length.LengthTests.test_basic",
# range lookup includes incorrect values.
"expressions.tests.IterableLookupInnerExpressionsTests.test_expressions_in_lookups_join_choice",
# Unexpected alias_refcount in alias_map.
"queries.tests.Queries1Tests.test_order_by_tables",
# The $sum aggregation returns 0 instead of None for null.
Expand Down

0 comments on commit 5c29684

Please sign in to comment.