mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #36358 -- Corrected introspection of composite primary keys on SQLite.
Previously, any first field of a composite primary key with type `INTEGER` was incorrectly introspected as an `AutoField` due to SQLite treating `INTEGER PRIMARY KEY` as an alias for the `ROWID`. This change ensures that integer fields in composite PKs are not mistaken for auto-incrementing fields. Thanks Jacob Walls and Sarah Boyce for the reviews.
This commit is contained in:
@@ -628,10 +628,7 @@ class InspectDBTransactionalTests(TransactionTestCase):
|
||||
|
||||
def test_composite_primary_key(self):
|
||||
out = StringIO()
|
||||
if connection.vendor == "sqlite":
|
||||
field_type = connection.features.introspected_field_types["AutoField"]
|
||||
else:
|
||||
field_type = connection.features.introspected_field_types["IntegerField"]
|
||||
field_type = connection.features.introspected_field_types["IntegerField"]
|
||||
call_command("inspectdb", "inspectdb_compositeprimarykeymodel", stdout=out)
|
||||
output = out.getvalue()
|
||||
self.assertIn(
|
||||
@@ -639,8 +636,4 @@ class InspectDBTransactionalTests(TransactionTestCase):
|
||||
output,
|
||||
)
|
||||
self.assertIn(f"column_1 = models.{field_type}()", output)
|
||||
self.assertIn(
|
||||
"column_2 = models.%s()"
|
||||
% connection.features.introspected_field_types["IntegerField"],
|
||||
output,
|
||||
)
|
||||
self.assertIn(f"column_2 = models.{field_type}()", output)
|
||||
|
||||
Reference in New Issue
Block a user