Skip to content

Commit

Permalink
rename MongoQuery.mongo_query to match_mql
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Nov 1, 2024
1 parent 41d6433 commit 087000e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions django_mongodb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ def build_query(self, columns=None):
try:
expr = where.as_mql(self, self.connection) if where else {}
except FullResultSet:
query.mongo_query = {}
query.match_mql = {}
else:
query.mongo_query = {"$expr": expr}
query.match_mql = {"$expr": expr}
if extra_fields:
query.extra_fields = self.get_project_fields(extra_fields, force_expression=True)
query.subqueries = self.subqueries
Expand Down Expand Up @@ -722,7 +722,7 @@ def execute_sql(self, result_type):
prepared = prepared.as_mql(self, self.connection)
values[field.column] = prepared
try:
criteria = self.build_query().mongo_query
criteria = self.build_query().match_mql
except EmptyResultSet:
return 0
is_empty = not bool(values)
Expand Down
10 changes: 5 additions & 5 deletions django_mongodb/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, compiler):
self.compiler = compiler
self.query = compiler.query
self.ordering = []
self.mongo_query = {}
self.match_mql = {}
self.subqueries = None
self.lookup_pipeline = None
self.project_fields = None
Expand All @@ -56,14 +56,14 @@ def __init__(self, compiler):
self.subquery_lookup = None

def __repr__(self):
return f"<MongoQuery: {self.mongo_query!r} ORDER {self.ordering!r}>"
return f"<MongoQuery: {self.match_mql!r} ORDER {self.ordering!r}>"

@wrap_database_errors
def delete(self):
"""Execute a delete query."""
if self.compiler.subqueries:
raise NotSupportedError("Cannot use QuerySet.delete() when a subquery is required.")
return self.compiler.collection.delete_many(self.mongo_query).deleted_count
return self.compiler.collection.delete_many(self.match_mql).deleted_count

@wrap_database_errors
def get_cursor(self):
Expand All @@ -79,8 +79,8 @@ def get_pipeline(self):
pipeline.extend(self.lookup_pipeline)
for query in self.subqueries or ():
pipeline.extend(query.get_pipeline())
if self.mongo_query:
pipeline.append({"$match": self.mongo_query})
if self.match_mql:
pipeline.append({"$match": self.match_mql})
if self.aggregation_pipeline:
pipeline.extend(self.aggregation_pipeline)
if self.project_fields:
Expand Down

0 comments on commit 087000e

Please sign in to comment.