summaryrefslogtreecommitdiff
path: root/django/db/backends
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-09-15 21:42:51 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-09-15 21:42:51 +0000
commit5ce2e6c2c827cf877f73bf0e42e6afb7e6a71ccf (patch)
tree8c8c2fb8329e2db7dbfcf2c47026a11ff079e5c5 /django/db/backends
parentea9cd5421382c047e2cc140bd6736b54ba660793 (diff)
queryset-refactor: Merged to [6220]
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6337 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends')
-rw-r--r--django/db/backends/oracle/base.py44
-rw-r--r--django/db/backends/sqlite3/base.py8
2 files changed, 32 insertions, 20 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 76e5743539..dbb1d032eb 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -438,21 +438,6 @@ class FormatStylePlaceholderCursor(Database.Cursor):
"""
charset = 'utf-8'
- def _rewrite_args(self, query, params=None):
- if params is None:
- params = []
- else:
- params = self._format_params(params)
- args = [(':arg%d' % i) for i in range(len(params))]
- query = smart_str(query, self.charset) % tuple(args)
- # cx_Oracle wants no trailing ';' for SQL statements. For PL/SQL, it
- # it does want a trailing ';' but not a trailing '/'. However, these
- # characters must be included in the original query in case the query
- # is being passed to SQL*Plus.
- if query.endswith(';') or query.endswith('/'):
- query = query[:-1]
- return query, params
-
def _format_params(self, params):
if isinstance(params, dict):
result = {}
@@ -464,12 +449,35 @@ class FormatStylePlaceholderCursor(Database.Cursor):
return tuple([smart_str(p, self.charset, True) for p in params])
def execute(self, query, params=None):
- query, params = self._rewrite_args(query, params)
+ if params is None:
+ params = []
+ else:
+ params = self._format_params(params)
+ args = [(':arg%d' % i) for i in range(len(params))]
+ # cx_Oracle wants no trailing ';' for SQL statements. For PL/SQL, it
+ # it does want a trailing ';' but not a trailing '/'. However, these
+ # characters must be included in the original query in case the query
+ # is being passed to SQL*Plus.
+ if query.endswith(';') or query.endswith('/'):
+ query = query[:-1]
+ query = smart_str(query, self.charset) % tuple(args)
return Database.Cursor.execute(self, query, params)
def executemany(self, query, params=None):
- query, params = self._rewrite_args(query, params)
- return Database.Cursor.executemany(self, query, params)
+ try:
+ args = [(':arg%d' % i) for i in range(len(params[0]))]
+ except (IndexError, TypeError):
+ # No params given, nothing to do
+ return None
+ # cx_Oracle wants no trailing ';' for SQL statements. For PL/SQL, it
+ # it does want a trailing ';' but not a trailing '/'. However, these
+ # characters must be included in the original query in case the query
+ # is being passed to SQL*Plus.
+ if query.endswith(';') or query.endswith('/'):
+ query = query[:-1]
+ query = smart_str(query, self.charset) % tuple(args)
+ new_param_list = [self._format_params(i) for i in params]
+ return Database.Cursor.executemany(self, query, new_param_list)
def fetchone(self):
return to_unicode(Database.Cursor.fetchone(self))
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index a482a240cf..b4b445cd16 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -133,8 +133,12 @@ class SQLiteCursorWrapper(Database.Cursor):
return Database.Cursor.execute(self, query, params)
def executemany(self, query, param_list):
- query = self.convert_query(query, len(param_list[0]))
- return Database.Cursor.executemany(self, query, param_list)
+ try:
+ query = self.convert_query(query, len(param_list[0]))
+ return Database.Cursor.executemany(self, query, param_list)
+ except (IndexError,TypeError):
+ # No parameter list provided
+ return None
def convert_query(self, query, num_params):
return query % tuple("?" * num_params)