Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #2164 -- Create correct SQL when pk column name is not the same…

… as the

attribute name. Thanks, Russell Cloran.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3130 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 28e643743f595abfab3ae8f0c40363b709defb86 1 parent 8938d5e
Malcolm Tredinnick authored June 15, 2006
2  django/db/models/base.py
@@ -165,7 +165,7 @@ def save(self):
165 165
                 cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \
166 166
                     (backend.quote_name(self._meta.db_table),
167 167
                     ','.join(['%s=%%s' % backend.quote_name(f.column) for f in non_pks]),
168  
-                    backend.quote_name(self._meta.pk.attname)),
  168
+                    backend.quote_name(self._meta.pk.column)),
169 169
                     db_values + [pk_val])
170 170
             else:
171 171
                 record_exists = False
3  tests/modeltests/custom_pk/models.py
@@ -8,7 +8,8 @@
8 8
 from django.db import models
9 9
 
10 10
 class Employee(models.Model):
11  
-    employee_code = models.CharField(maxlength=10, primary_key=True)
  11
+    employee_code = models.CharField(maxlength=10, primary_key=True,
  12
+            db_column = 'code')
12 13
     first_name = models.CharField(maxlength=20)
13 14
     last_name = models.CharField(maxlength=20)
14 15
     class Meta:

0 notes on commit 28e6437

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