diff options
| author | Michael Manfre <mmanfre@gmail.com> | 2012-10-09 17:06:37 -0400 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2012-10-10 01:00:58 +0300 |
| commit | c2150d4d2c5342488e474825c67dd3210fafc0e7 (patch) | |
| tree | 5b50a1fec0c43676ddf57c03d6138f6095af8400 /django/db/models/sql/compiler.py | |
| parent | 252cd271e88e1c60fc49c06fac9d45e4c7f8750e (diff) | |
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.
Diffstat (limited to 'django/db/models/sql/compiler.py')
| -rw-r--r-- | django/db/models/sql/compiler.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index f6b6bba1d9..a68f6e0290 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -897,8 +897,11 @@ class SQLInsertCompiler(SQLCompiler): 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))) |
