Fix SchemaManagerFunctionalTestCase::testSwitchPrimaryKeyOrder() #6819
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original test was reworked in #5714 (3.5.x). Prior to the rework, the final assertion would look like this (which was correct):
dbal/tests/Schema/Platforms/MySQLSchemaTest.php
Lines 38 to 44 in 35741d6
After the rework, the assertion started looking like this (incorrect, note the column order):
dbal/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php
Line 1774 in a4a9b17
The version of the test after the rework produces the
$diff
but doesn't use it for anything (it's an unused variable). The diff was supposed to be applied to the database schema, and then the assertion should have been made that the new column order is now effective.Skipping the test
The test passes on MySQL and SQLite because the corresponding DBALs APIs were designed after MySQL. Specifically,
DROP INDEX PRIMARY
on MySQL (and, for some reason, on SQLite) drops the primary key. The Postgres implementation gets away with a hack – instead of dropping the index, it generates the PK name and drops the constraint:dbal/src/Platforms/PostgreSQLPlatform.php
Lines 368 to 375 in 369ab24
This hack is not implemented for other platforms, so they don't support dropping the PK and fail with a SQL error, which is a bug. This hack cannot be ported to the other platforms easily, because the auto-generated name there is less predictable. This issue could be addressed by replacing the "primary index" with
PrimaryKeyConstraint
, which, once introspected from the database, would hold the actual constraint name.