Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prevented InsertQuery from appending a 'RETURNING' clause when it's n…

…ot actually interested in the result. This was causing some problems for Oracle.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10047 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6309b40bc2a6c93506cef5ae0043743fb172acc1 1 parent a21770e
@ikelly ikelly authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 django/db/models/sql/subqueries.py
View
6 django/db/models/sql/subqueries.py
@@ -291,10 +291,11 @@ def __init__(self, *args, **kwargs):
self.columns = []
self.values = []
self.params = ()
+ self.return_id = False
def clone(self, klass=None, **kwargs):
extras = {'columns': self.columns[:], 'values': self.values[:],
- 'params': self.params}
+ 'params': self.params, 'return_id': self.return_id}
extras.update(kwargs)
return super(InsertQuery, self).clone(klass, **extras)
@@ -307,7 +308,7 @@ def as_sql(self):
result.append('(%s)' % ', '.join([qn(c) for c in self.columns]))
result.append('VALUES (%s)' % ', '.join(self.values))
params = self.params
- if self.connection.features.can_return_id_from_insert:
+ if self.return_id and self.connection.features.can_return_id_from_insert:
col = "%s.%s" % (qn(opts.db_table), qn(opts.pk.column))
r_fmt, r_params = self.connection.ops.return_insert_id()
result.append(r_fmt % col)
@@ -315,6 +316,7 @@ def as_sql(self):
return ' '.join(result), params
def execute_sql(self, return_id=False):
+ self.return_id = return_id
cursor = super(InsertQuery, self).execute_sql(None)
if not (return_id and cursor):
return
Please sign in to comment.
Something went wrong with that request. Please try again.