From 0e3393dd64dc4e56e057cfb5e96ce88dc62979eb Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Tue, 9 Oct 2012 17:06:37 -0400 Subject: [PATCH] Fixed #19096 - More extendable can_return_id_from_insert 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. --- django/db/models/sql/compiler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index f6b6bba1d9800..4fe29bd4dcda3 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -897,8 +897,9 @@ 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 + 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)))