Skip to content

Commit 6afab2d

Browse files
committed
Add expression wrap to parameters.
1 parent fe82dea commit 6afab2d

File tree

5 files changed

+158
-104
lines changed

5 files changed

+158
-104
lines changed

django_mongodb_backend/expressions/builtins.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def case(self, compiler, connection):
5353
}
5454

5555

56-
def col(self, compiler, connection): # noqa: ARG001
56+
def col(self, compiler, connection, as_path=False): # noqa: ARG001
5757
# If the column is part of a subquery and belongs to one of the parent
5858
# queries, it will be stored for reference using $let in a $lookup stage.
5959
# If the query is built with `alias_cols=False`, treat the column as
@@ -71,7 +71,11 @@ def col(self, compiler, connection): # noqa: ARG001
7171
# Add the column's collection's alias for columns in joined collections.
7272
has_alias = self.alias and self.alias != compiler.collection_name
7373
prefix = f"{self.alias}." if has_alias else ""
74-
return f"${prefix}{self.target.column}"
74+
return f"{prefix}{self.target.column}" if as_path else f"${prefix}{self.target.column}"
75+
76+
77+
def col_as_path(self, compiler, connection):
78+
return col(self, compiler, connection).lstrip("$")
7579

7680

7781
def col_pairs(self, compiler, connection):

0 commit comments

Comments
 (0)