1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

[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
This commit is contained in:
Alex Gaynor 2010-07-19 21:04:03 +00:00
parent a35cbdbeaf
commit 9c6e1c89c5
2 changed files with 8 additions and 1 deletions

View File

@ -25,6 +25,9 @@ class SQLCompiler(object):
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 File

@ -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 @@ class MongoTestCase(TestCase):
self.assert_unsupported(
lambda: Artist.objects.aggregate(Count("id"), Count("pk"))
)
self.assert_unsupported(
Artist.objects.filter(Q(pk=0) | Q(pk=1))
)