Author: mtredinnick
Date: 2009-04-11 19:13:03 -0500 (Sat, 11 Apr 2009)
New Revision: 10528

Modified:
   django/trunk/tests/regressiontests/queries/models.py
Log:
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.

Modified: django/trunk/tests/regressiontests/queries/models.py
===================================================================
--- django/trunk/tests/regressiontests/queries/models.py        2009-04-11 
22:31:28 UTC (rev 10527)
+++ django/trunk/tests/regressiontests/queries/models.py        2009-04-12 
00:13:03 UTC (rev 10528)
@@ -1126,6 +1126,23 @@
 >>> 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__


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to