28
28
from ..query_utils import process_lhs
29
29
30
30
31
- def case (self , compiler , connection ):
31
+ # EXTRA IS TOTALLY IGNORED
32
+ def case (self , compiler , connection , ** extra ): # noqa: ARG001
32
33
case_parts = []
33
34
for case in self .cases :
34
35
case_mql = {}
@@ -53,7 +54,7 @@ def case(self, compiler, connection):
53
54
}
54
55
55
56
56
- def col (self , compiler , connection , as_path = False ): # noqa: ARG001
57
+ def col (self , compiler , connection , as_path = False , as_expr = None ): # noqa: ARG001
57
58
# If the column is part of a subquery and belongs to one of the parent
58
59
# queries, it will be stored for reference using $let in a $lookup stage.
59
60
# If the query is built with `alias_cols=False`, treat the column as
@@ -71,7 +72,7 @@ def col(self, compiler, connection, as_path=False): # noqa: ARG001
71
72
# Add the column's collection's alias for columns in joined collections.
72
73
has_alias = self .alias and self .alias != compiler .collection_name
73
74
prefix = f"{ self .alias } ." if has_alias else ""
74
- if not as_path :
75
+ if not as_path or as_expr :
75
76
prefix = f"${ prefix } "
76
77
return f"{ prefix } { self .target .column } "
77
78
@@ -83,16 +84,16 @@ def col_pairs(self, compiler, connection):
83
84
return cols [0 ].as_mql (compiler , connection )
84
85
85
86
86
- def combined_expression (self , compiler , connection ):
87
+ def combined_expression (self , compiler , connection , ** extra ):
87
88
expressions = [
88
- self .lhs .as_mql (compiler , connection ),
89
- self .rhs .as_mql (compiler , connection ),
89
+ self .lhs .as_mql (compiler , connection , ** extra ),
90
+ self .rhs .as_mql (compiler , connection , ** extra ),
90
91
]
91
92
return connection .ops .combine_expression (self .connector , expressions )
92
93
93
94
94
- def expression_wrapper (self , compiler , connection ):
95
- return self .expression .as_mql (compiler , connection )
95
+ def expression_wrapper (self , compiler , connection , ** extra ):
96
+ return self .expression .as_mql (compiler , connection , ** extra )
96
97
97
98
98
99
def negated_expression (self , compiler , connection ):
@@ -103,7 +104,7 @@ def order_by(self, compiler, connection):
103
104
return self .expression .as_mql (compiler , connection )
104
105
105
106
106
- def query (self , compiler , connection , get_wrapping_pipeline = None , as_path = False ):
107
+ def query (self , compiler , connection , get_wrapping_pipeline = None , as_path = False , as_expr = None ):
107
108
subquery_compiler = self .get_compiler (connection = connection )
108
109
subquery_compiler .pre_sql_setup (with_col_aliases = False )
109
110
field_name , expr = subquery_compiler .columns [0 ]
@@ -145,7 +146,7 @@ def query(self, compiler, connection, get_wrapping_pipeline=None, as_path=False)
145
146
# Erase project_fields since the required value is projected above.
146
147
subquery .project_fields = None
147
148
compiler .subqueries .append (subquery )
148
- if as_path :
149
+ if as_path and not as_expr :
149
150
return f"{ table_output } .{ field_name } "
150
151
return f"${ table_output } .{ field_name } "
151
152
@@ -200,7 +201,7 @@ def when(self, compiler, connection, **extra):
200
201
return self .condition .as_mql (compiler , connection , ** extra )
201
202
202
203
203
- def value (self , compiler , connection ): # noqa: ARG001
204
+ def value (self , compiler , connection , ** extra ): # noqa: ARG001
204
205
value = self .value
205
206
if isinstance (value , (list , int )):
206
207
# Wrap lists & numbers in $literal to prevent ambiguity when Value
0 commit comments