1
0
mirror of https://github.com/django/django.git synced 2024-12-25 18:46:22 +00:00

Changed meta.py save() code from [507] to work under sqlite. All tests now pass in all 3 database backends.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@510 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-08-15 20:03:34 +00:00
parent 7cfddb3c43
commit c727729183

View File

@ -735,7 +735,7 @@ def method_save(opts, self):
# Determine whether a record with the primary key already exists.
cursor.execute("SELECT 1 FROM %s WHERE %s=%%s LIMIT 1" % (opts.db_table, opts.pk.name), [pk_val])
# If it does already exist, do an UPDATE.
if cursor.rowcount > 0:
if cursor.fetchone():
db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.name), False)) for f in non_pks]
cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % (opts.db_table,
','.join(['%s=%%s' % f.name for f in non_pks]), opts.pk.name),