summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-04-12 00:13:03 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-04-12 00:13:03 +0000
commit50dbda9a3eb83c9e2e79b7d56305a1f0700f8478 (patch)
tree385d55143cccbe9546188e6163295a81026da3b1 /tests
parentd7870d3444eed9525863b95549be479bdca1bc89 (diff)
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. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10528 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/queries/models.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 88d08b0bd1..b5fa377496 100644
--- a/tests/regressiontests/queries/models.py
+++ b/tests/regressiontests/queries/models.py
@@ -1126,6 +1126,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__