@@ -254,13 +254,6 @@ def __init__(self, lhs, rhs):
254254class ArrayContains (ArrayRHSMixin , FieldGetDbPrepValueMixin , Lookup ):
255255 lookup_name = "contains"
256256
257- def as_mql_path (self , compiler , connection ):
258- lhs_mql = process_lhs (self , compiler , connection , as_path = True )
259- value = process_rhs (self , compiler , connection , as_path = True )
260- if value is None :
261- return False
262- return {lhs_mql : {"$all" : value }}
263-
264257 def as_mql_expr (self , compiler , connection ):
265258 lhs_mql = process_lhs (self , compiler , connection , as_path = False )
266259 value = process_rhs (self , compiler , connection , as_path = False )
@@ -272,6 +265,13 @@ def as_mql_expr(self, compiler, connection):
272265 ]
273266 }
274267
268+ def as_mql_path (self , compiler , connection ):
269+ lhs_mql = process_lhs (self , compiler , connection , as_path = True )
270+ value = process_rhs (self , compiler , connection , as_path = True )
271+ if value is None :
272+ return False
273+ return {lhs_mql : {"$all" : value }}
274+
275275
276276@ArrayField .register_lookup
277277class ArrayContainedBy (ArrayRHSMixin , FieldGetDbPrepValueMixin , Lookup ):
@@ -333,11 +333,6 @@ def get_subquery_wrapping_pipeline(self, compiler, connection, field_name, expr)
333333 },
334334 ]
335335
336- def as_mql_path (self , compiler , connection ):
337- lhs_mql = process_lhs (self , compiler , connection , as_path = True )
338- value = process_rhs (self , compiler , connection , as_path = True )
339- return {lhs_mql : {"$in" : value }}
340-
341336 def as_mql_expr (self , compiler , connection ):
342337 lhs_mql = process_lhs (self , compiler , connection , as_path = False )
343338 value = process_rhs (self , compiler , connection , as_path = False )
@@ -348,6 +343,11 @@ def as_mql_expr(self, compiler, connection):
348343 ]
349344 }
350345
346+ def as_mql_path (self , compiler , connection ):
347+ lhs_mql = process_lhs (self , compiler , connection , as_path = True )
348+ value = process_rhs (self , compiler , connection , as_path = True )
349+ return {lhs_mql : {"$in" : value }}
350+
351351
352352@ArrayField .register_lookup
353353class ArrayLenTransform (Transform ):
@@ -388,14 +388,14 @@ def is_simple_expression(self):
388388 def is_simple_column (self ):
389389 return self .lhs .is_simple_column
390390
391- def as_mql_path (self , compiler , connection ):
392- lhs_mql = process_lhs (self , compiler , connection , as_path = True )
393- return f"{ lhs_mql } .{ self .index } "
394-
395391 def as_mql_expr (self , compiler , connection ):
396392 lhs_mql = process_lhs (self , compiler , connection , as_path = False )
397393 return {"$arrayElemAt" : [lhs_mql , self .index ]}
398394
395+ def as_mql_path (self , compiler , connection ):
396+ lhs_mql = process_lhs (self , compiler , connection , as_path = True )
397+ return f"{ lhs_mql } .{ self .index } "
398+
399399 @property
400400 def output_field (self ):
401401 return self .base_field
0 commit comments