From 39fd198ddd8d0e6915dc713eeac5fef6f40b74ed Mon Sep 17 00:00:00 2001 From: Boulder Sprinters Date: Sat, 4 Nov 2006 22:19:44 +0000 Subject: [PATCH] [boulder-oracle-sprint] Replaced Oracle-specific LIMIT 1 for existence test with a generic SELECT COUNT(*) git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@3990 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/base.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/django/db/models/base.py b/django/db/models/base.py index 71f800f4bf..1224e3f697 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -171,11 +171,10 @@ class Model(object): record_exists = True if pk_set: # Determine whether a record with the primary key already exists. - lim = settings.DATABASE_ENGINE != 'oracle' and ' LIMIT 1' or '' - cursor.execute("SELECT 1 FROM %s WHERE %s=%%s %s" % \ - (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column), lim), [pk_val]) + cursor.execute("SELECT COUNT(*) FROM %s WHERE %s=%%s" % \ + (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)), [pk_val]) # If it does already exist, do an UPDATE. - if cursor.fetchone(): + if cursor.fetchone()[0] > 0: db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f in non_pks] if db_values: cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \