From 9c6e1c89c595de5b6bd3180d59faf944a3093d6d Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 19 Jul 2010 21:04:03 +0000 Subject: [PATCH] [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 --- django/contrib/mongodb/compiler.py | 3 +++ tests/regressiontests/mongodb/tests.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/django/contrib/mongodb/compiler.py b/django/contrib/mongodb/compiler.py index b9a12b04bf..c2a8c11b23 100644 --- a/django/contrib/mongodb/compiler.py +++ b/django/contrib/mongodb/compiler.py @@ -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: diff --git a/tests/regressiontests/mongodb/tests.py b/tests/regressiontests/mongodb/tests.py index 01bdd6c13a..42a45621e0 100644 --- a/tests/regressiontests/mongodb/tests.py +++ b/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 @@ 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)) + )