diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2006-08-10 03:55:03 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2006-08-10 03:55:03 +0000 |
| commit | a6a402a7db45ea7d2bb8521b989de573c4f72fee (patch) | |
| tree | 61e1257baf08d3bd5105cefaebe276e41f9e269c /django | |
| parent | cba451c94035ebf6174a283d5b1442dd4b995953 (diff) | |
Fixed #2512 -- Fixed SQL error when saving existing empty models.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3548 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index 657236571d..bdae7eccc2 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -176,11 +176,12 @@ class Model(object): # If it does already exist, do an UPDATE. if cursor.fetchone(): db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f in non_pks] - 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.column)), - db_values + [pk_val]) + if db_values: + 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.column)), + db_values + [pk_val]) else: record_exists = False if not pk_set or not record_exists: |
