diff options
author | Robin Munn <robin.munn@gmail.com> | 2007-01-31 23:43:09 +0000 |
---|---|---|
committer | Robin Munn <robin.munn@gmail.com> | 2007-01-31 23:43:09 +0000 |
commit | fe361e678a46dc4c717c79c2f12b3ba32293b81a (patch) | |
tree | 8f42488e7d95244bab3db7b2bf934e006940521a /tests/modeltests/or_lookups/models.py | |
parent | 122426e7453ed638a0c5be7e8b925adcddea3889 (diff) | |
download | django-fe361e678a46dc4c717c79c2f12b3ba32293b81a.tar.gz |
Merged revisions 4186 to 4454 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/sqlalchemy@4455 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/or_lookups/models.py')
-rw-r--r-- | tests/modeltests/or_lookups/models.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py index 2de18edc1f..9f926a7373 100644 --- a/tests/modeltests/or_lookups/models.py +++ b/tests/modeltests/or_lookups/models.py @@ -69,6 +69,21 @@ __test__ = {'API_TESTS':""" >>> Article.objects.filter(Q(pk=1) | Q(pk=2) | Q(pk=3)) [<Article: Hello>, <Article: Goodbye>, <Article: Hello and goodbye>] +# You could also use "in" to accomplish the same as above. +>>> Article.objects.filter(pk__in=[1,2,3]) +[<Article: Hello>, <Article: Goodbye>, <Article: Hello and goodbye>] + +>>> Article.objects.filter(pk__in=[1,2,3,4]) +[<Article: Hello>, <Article: Goodbye>, <Article: Hello and goodbye>] + +# Passing "in" an empty list returns no results ... +>>> Article.objects.filter(pk__in=[]) +[] + +# ... but can return results if we OR it with another query. +>>> Article.objects.filter(Q(pk__in=[]) | Q(headline__icontains='goodbye')) +[<Article: Goodbye>, <Article: Hello and goodbye>] + # Q arg objects are ANDed >>> Article.objects.filter(Q(headline__startswith='Hello'), Q(headline__contains='bye')) [<Article: Hello and goodbye>] |