67
67
68
68
def cast (self , compiler , connection ):
69
69
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 ]
71
71
if max_length := self .output_field .max_length :
72
72
lhs_mql = {"$substrCP" : [lhs_mql , 0 , max_length ]}
73
73
# Skip the conversion for "object" as it doesn't need to be transformed for
@@ -81,7 +81,7 @@ def cast(self, compiler, connection):
81
81
82
82
83
83
def 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 )
85
85
86
86
87
87
def concat_pair (self , compiler , connection ):
@@ -91,12 +91,12 @@ def concat_pair(self, compiler, connection):
91
91
92
92
93
93
def cot (self , compiler , connection ):
94
- lhs_mql = process_lhs (self , compiler , connection , as_path = False )
94
+ lhs_mql = process_lhs (self , compiler , connection )
95
95
return {"$divide" : [1 , {"$tan" : lhs_mql }]}
96
96
97
97
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 )
100
100
operator = EXTRACT_OPERATORS .get (self .lookup_name )
101
101
if operator is None :
102
102
raise NotSupportedError (f"{ self .__class__ .__name__ } is not supported." )
@@ -105,22 +105,8 @@ def extract(self, compiler, connection, as_path=False):
105
105
return {f"${ operator } " : lhs_mql }
106
106
107
107
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 )
124
110
if self .function is None :
125
111
raise NotSupportedError (f"{ self } may need an as_mql() method." )
126
112
operator = MONGO_OPERATORS .get (self .__class__ , self .function .lower ())
@@ -291,8 +277,8 @@ def register_functions():
291
277
ConcatPair .as_mql_expr = concat_pair
292
278
Cot .as_mql_expr = cot
293
279
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
296
282
JSONArray .as_mql_expr = process_lhs
297
283
Left .as_mql_expr = left
298
284
Length .as_mql_expr = length
@@ -312,4 +298,3 @@ def register_functions():
312
298
TruncDate .as_mql_expr = trunc_date
313
299
TruncTime .as_mql_expr = trunc_time
314
300
Upper .as_mql_expr = preserve_null ("toUpper" )
315
- Func .can_use_path = False
0 commit comments