@@ -128,20 +128,20 @@ def func_expr(self, compiler, connection):
128
128
129
129
130
130
def left (self , compiler , connection ):
131
- return self .get_substr ().as_mql (compiler , connection , as_path = False )
131
+ return self .get_substr ().as_mql (compiler , connection )
132
132
133
133
134
134
def length (self , compiler , connection ):
135
135
# Check for null first since $strLenCP only accepts strings.
136
- lhs_mql = process_lhs (self , compiler , connection , as_path = False )
136
+ lhs_mql = process_lhs (self , compiler , connection )
137
137
return {"$cond" : {"if" : {"$eq" : [lhs_mql , None ]}, "then" : None , "else" : {"$strLenCP" : lhs_mql }}}
138
138
139
139
140
140
def log (self , compiler , connection ):
141
141
# This function is usually log(base, num) but on MongoDB it's log(num, base).
142
142
clone = self .copy ()
143
143
clone .set_source_expressions (self .get_source_expressions ()[::- 1 ])
144
- return func (clone , compiler , connection , as_path = False )
144
+ return func (clone , compiler , connection )
145
145
146
146
147
147
def now (self , compiler , connection ): # noqa: ARG001
@@ -150,17 +150,15 @@ def now(self, compiler, connection): # noqa: ARG001
150
150
151
151
def null_if (self , compiler , connection ):
152
152
"""Return None if expr1==expr2 else expr1."""
153
- expr1 , expr2 = (
154
- expr .as_mql (compiler , connection , as_path = False ) for expr in self .get_source_expressions ()
155
- )
153
+ expr1 , expr2 = (expr .as_mql (compiler , connection ) for expr in self .get_source_expressions ())
156
154
return {"$cond" : {"if" : {"$eq" : [expr1 , expr2 ]}, "then" : None , "else" : expr1 }}
157
155
158
156
159
157
def preserve_null (operator ):
160
158
# If the argument is null, the function should return null, not
161
159
# $toLower/Upper's behavior of returning an empty string.
162
160
def wrapped (self , compiler , connection ):
163
- lhs_mql = process_lhs (self , compiler , connection , as_path = False )
161
+ lhs_mql = process_lhs (self , compiler , connection )
164
162
return {
165
163
"$cond" : {
166
164
"if" : connection .mongo_expr_operators ["isnull" ](lhs_mql , True ),
@@ -173,23 +171,18 @@ def wrapped(self, compiler, connection):
173
171
174
172
175
173
def replace (self , compiler , connection ):
176
- expression , text , replacement = process_lhs (self , compiler , connection , as_path = False )
174
+ expression , text , replacement = process_lhs (self , compiler , connection )
177
175
return {"$replaceAll" : {"input" : expression , "find" : text , "replacement" : replacement }}
178
176
179
177
180
178
def round_ (self , compiler , connection ):
181
179
# Round needs its own function because it's a special case that inherits
182
180
# from Transform but has two arguments.
183
- return {
184
- "$round" : [
185
- expr .as_mql (compiler , connection , as_path = False )
186
- for expr in self .get_source_expressions ()
187
- ]
188
- }
181
+ return {"$round" : [expr .as_mql (compiler , connection ) for expr in self .get_source_expressions ()]}
189
182
190
183
191
184
def str_index (self , compiler , connection ):
192
- lhs = process_lhs (self , compiler , connection , as_path = False )
185
+ lhs = process_lhs (self , compiler , connection )
193
186
# StrIndex should be 0-indexed (not found) but it's -1-indexed on MongoDB.
194
187
return {"$add" : [{"$indexOfCP" : lhs }, 1 ]}
195
188
@@ -253,7 +246,7 @@ def trunc_convert_value(self, value, expression, connection):
253
246
254
247
def trunc_date (self , compiler , connection ):
255
248
# Cast to date rather than truncate to date.
256
- lhs_mql = process_lhs (self , compiler , connection , as_path = False )
249
+ lhs_mql = process_lhs (self , compiler , connection )
257
250
tzname = self .get_tzname ()
258
251
if tzname and tzname != "UTC" :
259
252
raise NotSupportedError (f"TruncDate with tzinfo ({ tzname } ) isn't supported on MongoDB." )
@@ -276,7 +269,7 @@ def trunc_time(self, compiler, connection):
276
269
tzname = self .get_tzname ()
277
270
if tzname and tzname != "UTC" :
278
271
raise NotSupportedError (f"TruncTime with tzinfo ({ tzname } ) isn't supported on MongoDB." )
279
- lhs_mql = process_lhs (self , compiler , connection , as_path = False )
272
+ lhs_mql = process_lhs (self , compiler , connection )
280
273
return {
281
274
"$dateFromString" : {
282
275
"dateString" : {
0 commit comments