@@ -332,17 +332,15 @@ def build_query(self, columns=None):
332
332
"""Check if the query is supported and prepare a MongoQuery."""
333
333
self .check_query ()
334
334
query = self .query_class (self )
335
- query .aggregation_pipeline = self .aggregation_pipeline
336
335
query .lookup_pipeline = self .get_lookup_pipeline ()
337
336
query .order_by (self ._get_ordering ())
338
337
query .project_fields = self .get_project_fields (columns , ordering = query .ordering )
339
338
try :
340
- where = self .get_where ()
341
- query .mongo_query = (
342
- {"$expr" : where .as_mql (self , self .connection )} if where is not None else {}
343
- )
339
+ expr = self .where .as_mql (self , self .connection ) if self .where else {}
344
340
except FullResultSet :
345
341
query .mongo_query = {}
342
+ else :
343
+ query .mongo_query = {"$expr" : expr }
346
344
return query
347
345
348
346
def get_columns (self ):
@@ -480,9 +478,6 @@ def get_project_fields(self, columns=None, ordering=None):
480
478
fields [column ] = 1
481
479
return fields
482
480
483
- def get_where (self ):
484
- return self .where
485
-
486
481
487
482
class SQLInsertCompiler (SQLCompiler ):
488
483
def execute_sql (self , returning_fields = None ):
@@ -528,7 +523,8 @@ def check_query(self):
528
523
"Cannot use QuerySet.delete() when querying across multiple collections on MongoDB."
529
524
)
530
525
531
- def get_where (self ):
526
+ @property
527
+ def where (self ):
532
528
return self .query .where
533
529
534
530
@@ -592,15 +588,15 @@ def check_query(self):
592
588
"Cannot use QuerySet.update() when querying across multiple collections on MongoDB."
593
589
)
594
590
595
- def get_where (self ):
591
+ @property
592
+ def where (self ):
596
593
return self .query .where
597
594
598
595
599
596
class SQLAggregateCompiler (SQLCompiler ):
600
597
def build_query (self , columns = None ):
601
598
query = self .query_class (self )
602
599
query .project_fields = self .get_project_fields (tuple (self .annotations .items ()))
603
- query .aggregation_pipeline = self .aggregation_pipeline
604
600
compiler = self .query .inner_query .get_compiler (
605
601
self .using ,
606
602
elide_empty = self .elide_empty ,
0 commit comments