Skip to content
Browse files

[soc2010/query-refactor] Provide a more useful error message on disju…

…nctions.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13438 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent a35cbdb commit 9c6e1c89c595de5b6bd3180d59faf944a3093d6d @alex alex committed Jul 19, 2010
Showing with 8 additions and 1 deletion.
  1. +3 −0 django/contrib/mongodb/compiler.py
  2. +5 −1 tests/regressiontests/mongodb/tests.py
View
3 django/contrib/mongodb/compiler.py
@@ -25,6 +25,9 @@ def __init__(self, query, connection, using):
self.using = using
def get_filters(self, where):
+ if where.connector != "AND":
+ raise UnsupportedDatabaseOperation("MongoDB only supports joining "
+ "filters with and, not or.")
assert where.connector == "AND"
filters = {}
for child in where.children:
View
6 tests/regressiontests/mongodb/tests.py
@@ -1,5 +1,5 @@
from django.db import connection, UnsupportedDatabaseOperation
-from django.db.models import Count, Sum, F
+from django.db.models import Count, Sum, F, Q
from django.test import TestCase
from models import Artist, Group
@@ -392,3 +392,7 @@ def test_unsupported_ops(self):
self.assert_unsupported(
lambda: Artist.objects.aggregate(Count("id"), Count("pk"))
)
+
+ self.assert_unsupported(
+ Artist.objects.filter(Q(pk=0) | Q(pk=1))
+ )

0 comments on commit 9c6e1c8

Please sign in to comment.
Something went wrong with that request. Please try again.