Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #19096 -- Made can_return_id_from_insert more extendable

RETURNING is an extension of the SQL standard, which is not implemented
the same by all databases. Allow DatabaseOperations.return_insert_id to
return a None to allow for other 3rd party backends with a different
implementation.
  • Loading branch information...
commit c2150d4d2c5342488e474825c67dd3210fafc0e7 1 parent 252cd27
@manfre manfre authored akaariai committed
Showing with 5 additions and 2 deletions.
  1. +5 −2 django/db/models/sql/compiler.py
View
7 django/db/models/sql/compiler.py
@@ -897,8 +897,11 @@ def as_sql(self):
col = "%s.%s" % (qn(opts.db_table), qn(opts.pk.column))
result.append("VALUES (%s)" % ", ".join(placeholders[0]))
r_fmt, r_params = self.connection.ops.return_insert_id()
- result.append(r_fmt % col)
- params += r_params
+ # Skip empty r_fmt to allow subclasses to customize behaviour for
+ # 3rd party backends. Refs #19096.
+ if r_fmt:
+ result.append(r_fmt % col)
+ params += r_params
return [(" ".join(result), tuple(params))]
if can_bulk:
result.append(self.connection.ops.bulk_insert_sql(fields, len(values)))
Please sign in to comment.
Something went wrong with that request. Please try again.