Skip to content

Commit 08ef1f3

Browse files
committed
handle escpecial characters.
1 parent 9338093 commit 08ef1f3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

django_mongodb_backend/expressions/builtins.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,9 @@ def value(self, compiler, connection, as_path=False): # noqa: ARG001
241241

242242
@staticmethod
243243
def _is_constant_value(value):
244-
if isinstance(value, Array):
245-
return all(_is_constant_value(e) for e in value.get_source_expressions())
244+
if isinstance(value, list | Array):
245+
iterable = value.get_source_expressions() if isinstance(value, Array) else value
246+
return all(_is_constant_value(e) for e in iterable)
246247
if isinstance(value, Value) or is_direct_value(value):
247248
v = value.value if isinstance(value, Value) else value
248249
return not isinstance(v, str) or "." not in v

django_mongodb_backend/fields/json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ def _has_key_predicate(path, root_column=None, negated=False, as_path=False):
7373

7474
def has_key_lookup(self, compiler, connection, as_path=False):
7575
"""Return MQL to check for the existence of a key."""
76+
as_path = as_path and self.is_simple_expression()
77+
lhs = process_lhs(self, compiler, connection, as_path=as_path)
7678
rhs = self.rhs
77-
lhs = process_lhs(self, compiler, connection)
7879
if not isinstance(rhs, (list, tuple)):
7980
rhs = [rhs]
80-
as_path = as_path and self.is_simple_expression()
8181
paths = []
8282
# Transform any "raw" keys into KeyTransforms to allow consistent handling
8383
# in the code that follows.

0 commit comments

Comments
 (0)