Code

Ticket #14019: 13448.diff

File 13448.diff, 849 bytes (added by mlavin, 4 years ago)
Line 
1Index: django/db/models/sql/compiler.py
2===================================================================
3--- django/db/models/sql/compiler.py    (revision 13448)
4+++ django/db/models/sql/compiler.py    (working copy)
5@@ -771,7 +771,10 @@
6         values = [self.placeholder(*v) for v in self.query.values]
7         result.append('VALUES (%s)' % ', '.join(values))
8         params = self.query.params
9-        if self.return_id and self.connection.features.can_return_id_from_insert:
10+        return_id = False
11+        if hasattr(self, 'return_id'):
12+            return_id = self.return_id
13+        if return_id and self.connection.features.can_return_id_from_insert:
14             col = "%s.%s" % (qn(opts.db_table), qn(opts.pk.column))
15             r_fmt, r_params = self.connection.ops.return_insert_id()
16             result.append(r_fmt % col)