summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-04-28 23:35:04 -0400
committernessita <124304+nessita@users.noreply.github.com>2025-04-30 10:51:48 -0300
commit07100db6f46255ec6ef70b860495f977473684d6 (patch)
tree74b23bbbd9062779951bc195afadb9602a06d34a /tests
parent4c75858135589f3a00e32eb4d476074536371a32 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/inspectdb/tests.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py
index c5f4ba4c6c..8c544c58c3 100644
--- a/tests/inspectdb/tests.py
+++ b/tests/inspectdb/tests.py
@@ -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)