Skip to content

Commit 9bd5b59

Browse files
committed
add NotSupportedError for QuerySet.distinct().count()
1 parent 4640324 commit 9bd5b59

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

django_mongodb/compiler.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ def check_query(self):
9090
"""Check if the current query is supported by the database."""
9191
if self.query.is_empty():
9292
raise EmptyResultSet()
93-
if self.query.distinct:
93+
if self.query.distinct or getattr(
94+
# In the case of Query.distinct().count(), the distinct attribute
95+
# will be set on the inner_query.
96+
getattr(self.query, "inner_query", None),
97+
"distinct",
98+
None,
99+
):
94100
# This is a heuristic to detect QuerySet.datetimes() and dates().
95101
# "datetimefield" and "datefield" are the names of the annotations
96102
# the methods use. A user could annotate with the same names which

0 commit comments

Comments
 (0)