﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36358	Tables with composite primary keys including integer columns improperly get introspected as AutoField on SQLite	Simon Charette	Simon Charette	"Given a models defined like

{{{#!python
class CompositePk(models.Model):
    pk = models.CompositePrimaryKey(""field1"", ""field2"")
    field1 = models.IntegerField()
    field2 = models.IntegerField()
}}}

it incorrectly gets introspected as

{{{#!python
class CompositePk(models.Model):
    pk = models.CompositePrimaryKey(""field1"", ""field2"")
    field1 = models.AutoField()
    field2 = models.IntegerField()
}}}

on SQLite which was missed by #36052 (a8e4fd11efc65832e7d9f5582d3868c5c8bd8d88) when support for composite primary introspection was added even if the pre-existing test encoded this qwirk.

This is likely due to the fact that [https://www.sqlite.org/autoinc.html SQLite surprisingly treats any integer field primary key as auto-incrementing] even if not explicitly specified

> In SQLite, a column with type `INTEGER PRIMARY KEY` is an alias for the `ROWID` (except in `WITHOUT ROWID` tables) which is always a 64-bit signed integer.

which was known when `AutoField` introspection was added in #23748 (a35d2a4510d5beec398b1007aaa26492d6aedf97) see ticket:23748#comment:11 but the override of `get_field_type` was not properly adjusted when composite primary key introspection was added in #32234.

Marking as a release blocker as it's a bug in a newly released feature."	Bug	closed	Database layer (models, ORM)	5.2	Release blocker	fixed			Ready for checkin	1	0	0	0	0	0
