Refs #36052, #32234 -- Removed create_test_table_with_composite_primary_key flag in favor of using CompositePrimaryKey.

Now that Django properly supports creating models with composite primary
keys, the tests should use a `CompositePrimaryKey` field instead of a
feature flag to inline backend specific SQL for creating a composite PK.

Specifcially, the inspectdb's test_composite_primary_key was adjusted to
use schema editor instead of per-backend raw SQL.
This commit is contained in:
Simon Charette 2025-04-28 22:46:13 -04:00 committed by nessita
parent 8ef4e0bd42
commit 4c75858135
7 changed files with 7 additions and 37 deletions

View file

@ -626,17 +626,13 @@ class InspectDBTransactionalTests(TransactionTestCase):
self.assertIn(foreign_table_model, output)
self.assertIn(foreign_table_managed, output)
@skipUnlessDBFeature("create_test_table_with_composite_primary_key")
def test_composite_primary_key(self):
table_name = "test_table_composite_pk"
cursor_execute(connection.features.create_test_table_with_composite_primary_key)
self.addCleanup(cursor_execute, "DROP TABLE %s" % table_name)
out = StringIO()
if connection.vendor == "sqlite":
field_type = connection.features.introspected_field_types["AutoField"]
else:
field_type = connection.features.introspected_field_types["IntegerField"]
call_command("inspectdb", table_name, stdout=out)
call_command("inspectdb", "inspectdb_compositeprimarykeymodel", stdout=out)
output = out.getvalue()
self.assertIn(
"pk = models.CompositePrimaryKey('column_1', 'column_2')",