diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-12-08 02:39:51 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-12-08 02:39:51 +0000 |
| commit | 33c0f0de676ae8fd2c406beebb2f113aeb95fee7 (patch) | |
| tree | e113ddde45ccf7153122d1884f4c4436d096d4ed /tests/regressiontests | |
| parent | d4f0ae42a2ed4894b3eccb613df0d75e582330a6 (diff) | |
This fixes a group of problems in the SQL created by QuerySet.exclude() when
used in a few situations where NULL results can appear.
Fixed #8921 (the only ticket I know of that noticed any of these).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9590 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/queries/models.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 5a41af8dc6..868200f60c 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -675,7 +675,7 @@ thus fail.) ... s.reverse() ... params.reverse() -# This slightly odd comparison works aorund the fact that PostgreSQL will +# This slightly odd comparison works around the fact that PostgreSQL will # return 'one' and 'two' as strings, not Unicode objects. It's a side-effect of # using constants here and not a real concern. >>> d = Item.objects.extra(select=SortedDict(s), select_params=params).values('a', 'b')[0] @@ -742,7 +742,7 @@ We can do slicing beyond what is currently in the result cache, too. ## only apparent much later when the full test suite runs. I don't understand ## what's going on here yet. ## -## # We need to mess with the implemenation internals a bit here to decrease the +## # We need to mess with the implementation internals a bit here to decrease the ## # cache fill size so that we don't read all the results at once. ## >>> from django.db.models import query ## >>> query.ITER_CHUNK_SIZE = 2 @@ -795,7 +795,7 @@ More twisted cases, involving nested negations. [<Item: four>, <Item: one>, <Item: three>] Bug #7095 -Updates that are filtered on the model being updated are somewhat tricky to get +Updates that are filtered on the model being updated are somewhat tricky in MySQL. This exercises that case. >>> mm = ManagedModel.objects.create(data='mm1', tag=t1, public=True) >>> ManagedModel.objects.update(data='mm') @@ -998,13 +998,28 @@ model. But it should still be possible to add new ordering after that. >>> 'ORDER BY' in qs.query.as_sql()[0] True -Bug #9188 -- incorrect SQL was being generated for certain types of -exclude() queries that crossed multi-valued relations. +Incorrect SQL was being generated for certain types of exclude() queries that +crossed multi-valued relations (#8921, #9188 and some pre-emptively discovered +cases). >>> PointerA.objects.filter(connection__pointerb__id=1) [] >>> PointerA.objects.exclude(connection__pointerb__id=1) [] + +>>> Tag.objects.exclude(children=None) +[<Tag: t1>, <Tag: t3>] + +# This example is tricky because the parent could be NULL, so only checking +# parents with annotations omits some results (tag t1, in this case). +>>> Tag.objects.exclude(parent__annotation__name="a1") +[<Tag: t1>, <Tag: t4>, <Tag: t5>] + +# The annotation->tag link is single values and tag->children links is +# multi-valued. So we have to split the exclude filter in the middle and then +# optimise the inner query without losing results. +>>> Annotation.objects.exclude(tag__children__name="t2") +[<Annotation: a2>] """} # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__ |
