Skip to content

Commit cc80665

Browse files
committed
execute conversion query on self.match_mql stage
1 parent deac776 commit cc80665

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

django_mongodb_backend/query.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from django.db.models.sql.where import AND, OR, XOR, ExtraWhere, NothingNode, WhereNode
1212
from pymongo.errors import BulkWriteError, DuplicateKeyError, PyMongoError
1313

14+
from django_mongodb_backend.query_conversion.query_optimizer import QueryOptimizer
15+
1416

1517
def wrap_database_errors(func):
1618
@wraps(func)
@@ -87,7 +89,7 @@ def get_pipeline(self):
8789
for query in self.subqueries or ():
8890
pipeline.extend(query.get_pipeline())
8991
if self.match_mql:
90-
pipeline.append({"$match": self.match_mql})
92+
pipeline.append(QueryOptimizer().optimize(self.match_mql))
9193
if self.aggregation_pipeline:
9294
pipeline.extend(self.aggregation_pipeline)
9395
if self.project_fields:

0 commit comments

Comments
 (0)