Skip to content

Commit 9c6e1c8

Browse files
committed
[soc2010/query-refactor] Provide a more useful error message on disjunctions.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13438 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent a35cbdb commit 9c6e1c8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

django/contrib/mongodb/compiler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def __init__(self, query, connection, using):
2525
self.using = using
2626

2727
def get_filters(self, where):
28+
if where.connector != "AND":
29+
raise UnsupportedDatabaseOperation("MongoDB only supports joining "
30+
"filters with and, not or.")
2831
assert where.connector == "AND"
2932
filters = {}
3033
for child in where.children:

tests/regressiontests/mongodb/tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.db import connection, UnsupportedDatabaseOperation
2-
from django.db.models import Count, Sum, F
2+
from django.db.models import Count, Sum, F, Q
33
from django.test import TestCase
44

55
from models import Artist, Group
@@ -392,3 +392,7 @@ def test_unsupported_ops(self):
392392
self.assert_unsupported(
393393
lambda: Artist.objects.aggregate(Count("id"), Count("pk"))
394394
)
395+
396+
self.assert_unsupported(
397+
Artist.objects.filter(Q(pk=0) | Q(pk=1))
398+
)

0 commit comments

Comments
 (0)