diff options
| author | Karen Tracey <kmtracey@gmail.com> | 2009-04-21 17:56:54 +0000 |
|---|---|---|
| committer | Karen Tracey <kmtracey@gmail.com> | 2009-04-21 17:56:54 +0000 |
| commit | a486c1e9b60f145f6ef867ea64a3c8beb750f5cf (patch) | |
| tree | 11b267fe839d6fc6ffe1ac0e5e7d0c9e96721c8a /tests | |
| parent | 40a7b54a00561c307b3e5d9ec694bbdbe0f8cff2 (diff) | |
[1.0.X] Added a test from Jamie Gennis to ensure #9848 doesn't reappear.
The bug itself was fixed at some point in the past months (there have
been a few improvements to update() recently). Fixed #9848.
(Merge of r10528 from trunk. Per comment in #9848 the fix was in r9967,
which was backported in r9968, thus it seems right to backport the new
test as well.)
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10607 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/queries/models.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 3f8c9e6a07..229b2fea1b 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -1096,6 +1096,23 @@ Bug #10432 (see also the Python 2.4+ tests for this, below). Testing an empty >>> list(Note.objects.filter(pk__in=g())) == [n_obj] True +Make sure that updates which only filter on sub-tables don't inadvertently +update the wrong records (bug #9848). + +# Make sure that the IDs from different tables don't happen to match. +>>> Ranking.objects.filter(author__name='a1') +[<Ranking: 3: a1>] +>>> Ranking.objects.filter(author__name='a1').update(rank='4') +1 +>>> r = Ranking.objects.filter(author__name='a1')[0] +>>> r.id != r.author.id +True +>>> r.rank +4 +>>> r.rank = 3 +>>> r.save() +>>> Ranking.objects.all() +[<Ranking: 3: a1>, <Ranking: 2: a2>, <Ranking: 1: a3>] """} # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__ |
