diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 43c8437..4f33277 100644
a
|
b
|
class Note(models.Model):
|
43 | 43 | ordering = ['note'] |
44 | 44 | |
45 | 45 | def __unicode__(self): |
46 | | return self.note |
| 46 | return ":".join([self.misc, self.note]) |
47 | 47 | |
48 | 48 | class Annotation(models.Model): |
49 | 49 | name = models.CharField(max_length=10) |
… |
… |
Bugs #2874, #3002
|
648 | 648 | # This is also a good select_related() test because there are multiple Note |
649 | 649 | # entries in the SQL. The two Note items should be different. |
650 | 650 | >>> qs[0].note, qs[0].creator.extra.note |
651 | | (<Note: n2>, <Note: n1>) |
| 651 | (<Note: bar:n2>, <Note: foo:n1>) |
652 | 652 | |
653 | 653 | Bug #3037 |
654 | 654 | >>> Item.objects.filter(Q(creator__name='a3', name='two')|Q(creator__name='a4', name='four')) |
… |
… |
True
|
684 | 684 | |
685 | 685 | Bug #5261 |
686 | 686 | >>> Note.objects.exclude(Q()) |
687 | | [<Note: n1>, <Note: n2>, <Note: n3>] |
| 687 | [<Note: foo:n1>, <Note: bar:n2>, <Note: foo:n3>] |
688 | 688 | |
689 | 689 | Bug #3045, #3288 |
690 | 690 | Once upon a time, select_related() with circular relations would loop |
… |
… |
Bug #7107 -- this shouldn't create an infinite loop.
|
897 | 897 | |
898 | 898 | Empty querysets can be merged with others. |
899 | 899 | >>> Note.objects.none() | Note.objects.all() |
900 | | [<Note: n1>, <Note: n2>, <Note: n3>] |
| 900 | [<Note: foo:n1>, <Note: bar:n2>, <Note: foo:n3>] |
901 | 901 | >>> Note.objects.all() | Note.objects.none() |
902 | | [<Note: n1>, <Note: n2>, <Note: n3>] |
| 902 | [<Note: foo:n1>, <Note: bar:n2>, <Note: foo:n3>] |
903 | 903 | >>> Note.objects.none() & Note.objects.all() |
904 | 904 | [] |
905 | 905 | >>> Note.objects.all() & Note.objects.none() |
… |
… |
relations.
|
1068 | 1068 | [<Annotation: a1>] |
1069 | 1069 | >>> xx = ExtraInfo.objects.create(info='xx', note=n3) |
1070 | 1070 | >>> Note.objects.filter(Q(extrainfo__author=a1)|Q(extrainfo=xx)) |
1071 | | [<Note: n1>, <Note: n3>] |
| 1071 | [<Note: foo:n1>, <Note: foo:n3>] |
1072 | 1072 | >>> xx.delete() |
1073 | 1073 | >>> q = Note.objects.filter(Q(extrainfo__author=a1)|Q(extrainfo=xx)).query |
1074 | 1074 | >>> len([x[2] for x in q.alias_map.values() if x[2] == q.LOUTER and q.alias_refcount[x[1]]]) |
diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
index 5699b60..f70fda8 100644
a
|
b
|
|
1 | 1 | import unittest |
2 | | from models import Tag, Annotation |
3 | | from django.db.models import Count |
| 2 | |
| 3 | from django.db.models import Count, Q |
| 4 | from django.test import TestCase |
| 5 | |
| 6 | from models import Tag, Annotation, Note |
| 7 | |
4 | 8 | |
5 | 9 | class QuerysetOrderedTests(unittest.TestCase): |
6 | 10 | """ |
… |
… |
class QuerysetOrderedTests(unittest.TestCase):
|
24 | 28 | qs = Annotation.objects.annotate(num_notes=Count('notes')) |
25 | 29 | self.assertEqual(qs.ordered, False) |
26 | 30 | self.assertEqual(qs.order_by('num_notes').ordered, True) |
27 | | |
28 | | No newline at end of file |
| 31 | |
| 32 | class ExcludeTestCase(TestCase): |
| 33 | def test_disjunction(self): |
| 34 | pypy = [ |
| 35 | Note.objects.create(misc="a%d" % i, note="PyPy!") for i in range(3) |
| 36 | ] |
| 37 | unladen = [ |
| 38 | Note.objects.create(misc="a%d" % i, note="Unladen Swallow!") |
| 39 | for i in range(3) |
| 40 | ] |
| 41 | cpython = [ |
| 42 | Note.objects.create(misc="a%d" % i, note="CPython!") for i in range(3) |
| 43 | ] |
| 44 | |
| 45 | self.assertEqual( |
| 46 | list(Note.objects.exclude(note="PyPy!").exclude(note="Unladen Swallow!")), |
| 47 | cpython |
| 48 | ) |
| 49 | self.assertEqual( |
| 50 | list(Note.objects.exclude(Q(note="PyPy!") | Q(note="Unladen Swallow!"))), |
| 51 | cpython |
| 52 | ) |