summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-15 03:32:11 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-15 03:32:11 +0000
commita3b22d9db07ab21bda752f765b0a4414c73dee57 (patch)
treea1c5d75642aab2d8cda3286e0b7b24421e1db743 /tests
parentf74464da52e28c513ee008022ce70717672e346e (diff)
queryset-refactor: Added ~ support to Q-objects. Based heavily on a patch from
Collin Grady. Refs #4858. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6518 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/or_lookups/models.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py
index 5dc8351054..b3500f27e7 100644
--- a/tests/modeltests/or_lookups/models.py
+++ b/tests/modeltests/or_lookups/models.py
@@ -90,6 +90,17 @@ __test__ = {'API_TESTS':"""
>>> Article.objects.filter(Q(headline__contains='bye'), headline__startswith='Hello')
[<Article: Hello and goodbye>]
+# Q objects can be negated
+>>> Article.objects.filter(Q(pk=1) | ~Q(pk=2))
+[<Article: Hello>, <Article: Hello and goodbye>]
+>>> Article.objects.filter(~Q(pk=1) & ~Q(pk=2))
+[<Article: Hello and goodbye>]
+
+# This allows for more complex queries than filter() and exclude() alone would
+# allow
+>>> Article.objects.filter(Q(pk=1) & (~Q(pk=2) | Q(pk=3)))
+[<Article: Hello>]
+
# Try some arg queries with operations other than get_list
>>> Article.objects.get(Q(headline__startswith='Hello'), Q(headline__contains='bye'))
<Article: Hello and goodbye>