Skip to content

Commit 9bca50f

Browse files
committed
made empty query handling use NothingNode
This is consistent with Django's SQLCompiler.
1 parent c518c33 commit 9bca50f

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

django_mongodb/compiler.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ def cursor_iter(self, cursor, chunk_size, columns):
119119

120120
def check_query(self):
121121
"""Check if the current query is supported by the database."""
122-
if self.query.is_empty():
123-
raise EmptyResultSet()
124122
if self.query.distinct or getattr(
125123
# In the case of Query.distinct().count(), the distinct attribute
126124
# will be set on the inner_query.

django_mongodb/query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.db.models.lookups import Exact
99
from django.db.models.sql.constants import INNER
1010
from django.db.models.sql.datastructures import Join
11-
from django.db.models.sql.where import AND, OR, XOR, WhereNode
11+
from django.db.models.sql.where import AND, OR, XOR, NothingNode, WhereNode
1212
from pymongo import ASCENDING, DESCENDING
1313
from pymongo.errors import DuplicateKeyError, PyMongoError
1414

@@ -282,4 +282,5 @@ def where_node(self, compiler, connection):
282282

283283
def register_nodes():
284284
Join.as_mql = join
285+
NothingNode.as_mql = NothingNode.as_sql
285286
WhereNode.as_mql = where_node

0 commit comments

Comments
 (0)