Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 50dbda9a3eb83c9e2e79b7d56305a1f0700f8478 1 parent d7870d3
Malcolm Tredinnick authored April 12, 2009

Showing 1 changed file with 17 additions and 0 deletions. Show diff stats Hide diff stats

  1. 17  tests/regressiontests/queries/models.py
17  tests/regressiontests/queries/models.py
@@ -1126,6 +1126,23 @@ def __unicode__(self):
1126 1126
 >>> list(Note.objects.filter(pk__in=g())) == [n_obj]
1127 1127
 True
1128 1128
 
  1129
+Make sure that updates which only filter on sub-tables don't inadvertently
  1130
+update the wrong records (bug #9848).
  1131
+
  1132
+# Make sure that the IDs from different tables don't happen to match.
  1133
+>>> Ranking.objects.filter(author__name='a1')
  1134
+[<Ranking: 3: a1>]
  1135
+>>> Ranking.objects.filter(author__name='a1').update(rank='4')
  1136
+1
  1137
+>>> r = Ranking.objects.filter(author__name='a1')[0]
  1138
+>>> r.id != r.author.id
  1139
+True
  1140
+>>> r.rank
  1141
+4
  1142
+>>> r.rank = 3
  1143
+>>> r.save()
  1144
+>>> Ranking.objects.all()
  1145
+[<Ranking: 3: a1>, <Ranking: 2: a2>, <Ranking: 1: a3>]
1129 1146
 """}
1130 1147
 
1131 1148
 # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__

0 notes on commit 50dbda9

Please sign in to comment.
Something went wrong with that request. Please try again.