|
@@ -1817,6 +1817,7 @@ class SQLInsertCompiler(SQLCompiler):
|
|
|
)
|
|
|
opts = self.query.get_meta()
|
|
|
self.returning_fields = returning_fields
|
|
|
+ cols = []
|
|
|
with self.connection.cursor() as cursor:
|
|
|
for sql, params in self.as_sql():
|
|
|
cursor.execute(sql, params)
|
|
@@ -1827,6 +1828,7 @@ class SQLInsertCompiler(SQLCompiler):
|
|
|
and len(self.query.objs) > 1
|
|
|
):
|
|
|
rows = self.connection.ops.fetch_returned_insert_rows(cursor)
|
|
|
+ cols = [field.get_col(opts.db_table) for field in self.returning_fields]
|
|
|
elif self.connection.features.can_return_columns_from_insert:
|
|
|
assert len(self.query.objs) == 1
|
|
|
rows = [
|
|
@@ -1835,7 +1837,9 @@ class SQLInsertCompiler(SQLCompiler):
|
|
|
self.returning_params,
|
|
|
)
|
|
|
]
|
|
|
+ cols = [field.get_col(opts.db_table) for field in self.returning_fields]
|
|
|
else:
|
|
|
+ cols = [opts.pk.get_col(opts.db_table)]
|
|
|
rows = [
|
|
|
(
|
|
|
self.connection.ops.last_insert_id(
|
|
@@ -1845,7 +1849,6 @@ class SQLInsertCompiler(SQLCompiler):
|
|
|
),
|
|
|
)
|
|
|
]
|
|
|
- cols = [field.get_col(opts.db_table) for field in self.returning_fields]
|
|
|
converters = self.get_converters(cols)
|
|
|
if converters:
|
|
|
rows = list(self.apply_converters(rows, converters))
|