1
0
mirror of https://github.com/django/django.git synced 2025-03-12 18:30:48 +00:00

Refs #373 -- Removed unused composite pk code in SQLInsertCompiler.

This logic could only be exercised if the composite primary key included an
AutoField but it's not allowed yet (refs #35957).

It was also slightly broken as it expected the AutoField to always be the first
member of returning_fields.
This commit is contained in:
Simon Charette 2025-01-11 00:02:52 -05:00 committed by Sarah Boyce
parent 8bee7fa45c
commit bfcb34076e

View File

@ -9,7 +9,6 @@ from django.db import DatabaseError, NotSupportedError
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import ColPairs, F, OrderBy, RawSQL, Ref, Value
from django.db.models.fields import composite
from django.db.models.fields.composite import CompositePrimaryKey
from django.db.models.functions import Cast, Random
from django.db.models.lookups import Lookup
from django.db.models.query_utils import select_related_descend
@ -1911,18 +1910,6 @@ class SQLInsertCompiler(SQLCompiler):
)
]
cols = [field.get_col(opts.db_table) for field in self.returning_fields]
elif isinstance(opts.pk, CompositePrimaryKey):
returning_field = returning_fields[0]
cols = [returning_field.get_col(opts.db_table)]
rows = [
(
self.connection.ops.last_insert_id(
cursor,
opts.db_table,
returning_field.column,
),
)
]
else:
cols = [opts.pk.get_col(opts.db_table)]
rows = [
@ -1937,8 +1924,6 @@ class SQLInsertCompiler(SQLCompiler):
converters = self.get_converters(cols)
if converters:
rows = self.apply_converters(rows, converters)
if self.has_composite_fields(cols):
rows = self.composite_fields_to_tuples(rows, cols)
return list(rows)