6767
6868def cast (self , compiler , connection ):
6969 output_type = connection .data_types [self .output_field .get_internal_type ()]
70- lhs_mql = process_lhs (self , compiler , connection , as_path = False )[0 ]
70+ lhs_mql = process_lhs (self , compiler , connection )[0 ]
7171 if max_length := self .output_field .max_length :
7272 lhs_mql = {"$substrCP" : [lhs_mql , 0 , max_length ]}
7373 # Skip the conversion for "object" as it doesn't need to be transformed for
@@ -81,7 +81,7 @@ def cast(self, compiler, connection):
8181
8282
8383def concat (self , compiler , connection ):
84- return self .get_source_expressions ()[0 ].as_mql (compiler , connection , as_path = False )
84+ return self .get_source_expressions ()[0 ].as_mql (compiler , connection )
8585
8686
8787def concat_pair (self , compiler , connection ):
@@ -91,12 +91,12 @@ def concat_pair(self, compiler, connection):
9191
9292
9393def cot (self , compiler , connection ):
94- lhs_mql = process_lhs (self , compiler , connection , as_path = False )
94+ lhs_mql = process_lhs (self , compiler , connection )
9595 return {"$divide" : [1 , {"$tan" : lhs_mql }]}
9696
9797
98- def extract (self , compiler , connection , as_path = False ):
99- lhs_mql = process_lhs (self , compiler , connection , as_path = as_path )
98+ def extract (self , compiler , connection ):
99+ lhs_mql = process_lhs (self , compiler , connection )
100100 operator = EXTRACT_OPERATORS .get (self .lookup_name )
101101 if operator is None :
102102 raise NotSupportedError (f"{ self .__class__ .__name__ } is not supported." )
@@ -105,22 +105,8 @@ def extract(self, compiler, connection, as_path=False):
105105 return {f"${ operator } " : lhs_mql }
106106
107107
108- def func (self , compiler , connection , as_path = False ):
109- lhs_mql = process_lhs (self , compiler , connection , as_path = False )
110- if self .function is None :
111- raise NotSupportedError (f"{ self } may need an as_mql() method." )
112- operator = MONGO_OPERATORS .get (self .__class__ , self .function .lower ())
113- if as_path :
114- return {"$expr" : {f"${ operator } " : lhs_mql }}
115- return {f"${ operator } " : lhs_mql }
116-
117-
118- def func_path (self , compiler , connection ): # noqa: ARG001
119- raise NotSupportedError (f"{ self } may need an as_mql_path() method." )
120-
121-
122- def func_expr (self , compiler , connection ):
123- lhs_mql = process_lhs (self , compiler , connection , as_path = False )
108+ def func (self , compiler , connection ):
109+ lhs_mql = process_lhs (self , compiler , connection )
124110 if self .function is None :
125111 raise NotSupportedError (f"{ self } may need an as_mql() method." )
126112 operator = MONGO_OPERATORS .get (self .__class__ , self .function .lower ())
@@ -291,8 +277,8 @@ def register_functions():
291277 ConcatPair .as_mql_expr = concat_pair
292278 Cot .as_mql_expr = cot
293279 Extract .as_mql_expr = extract
294- Func .as_mql_path = func_path
295- Func .as_mql_expr = func_expr
280+ Func .as_mql_expr = func
281+ Func .can_use_path = False
296282 JSONArray .as_mql_expr = process_lhs
297283 Left .as_mql_expr = left
298284 Length .as_mql_expr = length
@@ -312,4 +298,3 @@ def register_functions():
312298 TruncDate .as_mql_expr = trunc_date
313299 TruncTime .as_mql_expr = trunc_time
314300 Upper .as_mql_expr = preserve_null ("toUpper" )
315- Func .can_use_path = False
0 commit comments