﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2164	[patch] Update SQL incorrect when db_column different to field name	Russell Cloran <russell@…>	Adrian Holovaty	"Hi,

When database column name is different to the field's name (attname), the update SQL is generated incorrectly. The following trivial patch fixes that:


{{{
--- django/db/models/base.py    (revision 3129)
+++ django/db/models/base.py    (working copy)
@@ -165,7 +165,7 @@
                 cursor.execute(""UPDATE %s SET %s WHERE %s=%%s"" % \
                     (backend.quote_name(self._meta.db_table),
                     ','.join(['%s=%%s' % backend.quote_name(f.column) for f in non_pks]),
-                    backend.quote_name(self._meta.pk.attname)),
+                    backend.quote_name(self._meta.pk.column)),
                     db_values + [pk_val])
             else:
                 record_exists = False
}}}

Russell"	defect	closed	Database layer (models, ORM)	dev	normal	fixed			Unreviewed	1	0	0	0	0	0
