@@ -54,7 +54,7 @@ def case(self, compiler, connection):
54
54
}
55
55
56
56
57
- def col (self , compiler , connection ): # noqa: ARG001
57
+ def col (self , compiler , connection , as_path = False ): # noqa: ARG001
58
58
# If the column is part of a subquery and belongs to one of the parent
59
59
# queries, it will be stored for reference using $let in a $lookup stage.
60
60
# If the query is built with `alias_cols=False`, treat the column as
@@ -72,7 +72,11 @@ def col(self, compiler, connection): # noqa: ARG001
72
72
# Add the column's collection's alias for columns in joined collections.
73
73
has_alias = self .alias and self .alias != compiler .collection_name
74
74
prefix = f"{ self .alias } ." if has_alias else ""
75
- return f"${ prefix } { self .target .column } "
75
+ return f"{ prefix } { self .target .column } " if as_path else f"${ prefix } { self .target .column } "
76
+
77
+
78
+ def col_as_path (self , compiler , connection ):
79
+ return col (self , compiler , connection ).lstrip ("$" )
76
80
77
81
78
82
def col_pairs (self , compiler , connection ):
@@ -94,8 +98,11 @@ def expression_wrapper(self, compiler, connection):
94
98
return self .expression .as_mql (compiler , connection )
95
99
96
100
97
- def f (self , compiler , connection ): # noqa: ARG001
98
- return f"${ self .name } "
101
+ def f (self , compiler , connection , as_path = False ):
102
+ expression = self .resolve_expression (compiler .query )
103
+ if as_path :
104
+ return expression .as_mql (compiler , connection , as_path = as_path )
105
+ return expression .as_mql (compiler , connection )
99
106
100
107
101
108
def negated_expression (self , compiler , connection ):
0 commit comments