Opened 12 years ago

Closed 12 years ago

#2164 closed defect (fixed)

[patch] Update SQL incorrect when db_column different to field name

Reported by: Russell Cloran <russell@…> Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



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/    (revision 3129)
+++ django/db/models/    (working copy)
@@ -165,7 +165,7 @@
                 cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \
                     ','.join(['%s=%%s' % backend.quote_name(f.column) for f in non_pks]),
-                    backend.quote_name(,
+                    backend.quote_name(,
                     db_values + [pk_val])
                 record_exists = False


Change History (1)

comment:1 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [3130]) Fixed #2164 -- Create correct SQL when pk column name is not the same as the
attribute name. Thanks, Russell Cloran.

Note: See TracTickets for help on using tickets.
Back to Top