@@ -254,13 +254,6 @@ def __init__(self, lhs, rhs):
254
254
class ArrayContains (ArrayRHSMixin , FieldGetDbPrepValueMixin , Lookup ):
255
255
lookup_name = "contains"
256
256
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
-
264
257
def as_mql_expr (self , compiler , connection ):
265
258
lhs_mql = process_lhs (self , compiler , connection , as_path = False )
266
259
value = process_rhs (self , compiler , connection , as_path = False )
@@ -272,6 +265,13 @@ def as_mql_expr(self, compiler, connection):
272
265
]
273
266
}
274
267
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
+
275
275
276
276
@ArrayField .register_lookup
277
277
class ArrayContainedBy (ArrayRHSMixin , FieldGetDbPrepValueMixin , Lookup ):
@@ -333,11 +333,6 @@ def get_subquery_wrapping_pipeline(self, compiler, connection, field_name, expr)
333
333
},
334
334
]
335
335
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
-
341
336
def as_mql_expr (self , compiler , connection ):
342
337
lhs_mql = process_lhs (self , compiler , connection , as_path = False )
343
338
value = process_rhs (self , compiler , connection , as_path = False )
@@ -348,6 +343,11 @@ def as_mql_expr(self, compiler, connection):
348
343
]
349
344
}
350
345
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
+
351
351
352
352
@ArrayField .register_lookup
353
353
class ArrayLenTransform (Transform ):
@@ -388,14 +388,14 @@ def is_simple_expression(self):
388
388
def is_simple_column (self ):
389
389
return self .lhs .is_simple_column
390
390
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
-
395
391
def as_mql_expr (self , compiler , connection ):
396
392
lhs_mql = process_lhs (self , compiler , connection , as_path = False )
397
393
return {"$arrayElemAt" : [lhs_mql , self .index ]}
398
394
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
+
399
399
@property
400
400
def output_field (self ):
401
401
return self .base_field
0 commit comments