Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #10438 -- Fixed MySQL backend behaviour for UPDATE behaviour.

We need to know the number of rows that are matched by an UPDATE query,
not just the number of rows that are changed. In the relatively unlikely
event that somebody was using Django's cursor proxy and relying on the
previous behaviour, well, that isn't the case any longer. We need to
this version.

Thanks to Daniel Tang for pointing out the solution here.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent a584a6b commit 77066516a066d69b3c396db40f3855c06f1f1f3f @malcolmt malcolmt committed
Showing with 4 additions and 1 deletion.
  1. +4 −1 django/db/backends/mysql/
5 django/db/backends/mysql/
@@ -22,7 +22,7 @@
raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__)
from MySQLdb.converters import conversions
-from MySQLdb.constants import FIELD_TYPE, FLAG
+from MySQLdb.constants import FIELD_TYPE, FLAG, CLIENT
from django.db.backends import *
from django.db.backends.signals import connection_created
@@ -274,6 +274,9 @@ def _cursor(self):
kwargs['host'] = settings_dict['DATABASE_HOST']
if settings_dict['DATABASE_PORT']:
kwargs['port'] = int(settings_dict['DATABASE_PORT'])
+ # We need the number of potentially affected rows after an
+ # "UPDATE", not the number of changed rows.
+ kwargs['client_flag'] = CLIENT.FOUND_ROWS
self.connection = Database.connect(**kwargs)
self.connection.encoders[SafeUnicode] = self.connection.encoders[unicode]

0 comments on commit 7706651

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