From aa9673746ff6680892fe9bff6b1f0c8a1b44bf17 Mon Sep 17 00:00:00 2001 From: David Maicher Date: Mon, 17 Jun 2024 22:02:35 +0200 Subject: [PATCH 1/4] Revert "Merge pull request #6413 from achterin/bugfix/foreign_key_name_change_detection" This reverts commit 080aab5a9588f137ef3e1ad7e0d056a4517b4e16, reversing changes made to a5d2bafb2b009cca29837db45ac6febe6c963859. --- src/Schema/Comparator.php | 4 ---- tests/Schema/AbstractComparatorTestCase.php | 9 ++++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Schema/Comparator.php b/src/Schema/Comparator.php index 804c981702b..28e7f2f73b2 100644 --- a/src/Schema/Comparator.php +++ b/src/Schema/Comparator.php @@ -555,10 +555,6 @@ private function detectRenamedIndexes(array &$addedIndexes, array &$removedIndex */ public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2) { - if (strtolower($key1->getName()) !== strtolower($key2->getName())) { - return true; - } - if ( array_map('strtolower', $key1->getUnquotedLocalColumns()) !== array_map('strtolower', $key2->getUnquotedLocalColumns()) diff --git a/tests/Schema/AbstractComparatorTestCase.php b/tests/Schema/AbstractComparatorTestCase.php index 0470c0cdfea..a087202628f 100644 --- a/tests/Schema/AbstractComparatorTestCase.php +++ b/tests/Schema/AbstractComparatorTestCase.php @@ -652,7 +652,7 @@ public function testCompareColumnCompareCaseInsensitive(): void self::assertFalse($tableDiff); } - public function testDetectIndexNameChange(): void + public function testCompareIndexBasedOnPropertiesNotName(): void { $tableA = new Table('foo'); $tableA->addColumn('id', Types::INTEGER); @@ -672,7 +672,7 @@ public function testDetectIndexNameChange(): void ); } - public function testDetectForeignKeyNameChange(): void + public function testCompareForeignKeyBasedOnPropertiesNotName(): void { $tableA = new Table('foo'); $tableA->addColumn('id', Types::INTEGER); @@ -683,9 +683,8 @@ public function testDetectForeignKeyNameChange(): void $tableB->addForeignKeyConstraint('bar', ['id'], ['id'], [], 'bar_constraint'); $tableDiff = $this->comparator->diffTable($tableA, $tableB); - self::assertNotFalse($tableDiff); - self::assertCount(1, $tableDiff->addedForeignKeys); - self::assertCount(1, $tableDiff->removedForeignKeys); + + self::assertFalse($tableDiff); } public function testCompareForeignKeyRestrictNoActionAreTheSame(): void From 032d9024df4eb37c0c88ff9bc31e8216da9f1e18 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 18 Jun 2024 14:06:51 +0200 Subject: [PATCH 2/4] PHPStan 1.11.5 (#6446) --- composer.json | 2 +- phpstan.neon.dist | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ab12807dace..3553f56f8e0 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "doctrine/coding-standard": "12.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.1", - "phpstan/phpstan": "1.11.1", + "phpstan/phpstan": "1.11.5", "phpstan/phpstan-strict-rules": "^1.6", "phpunit/phpunit": "9.6.19", "psalm/plugin-phpunit": "0.18.4", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9c3b2389430..e7a2aad5461 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -146,5 +146,11 @@ parameters: # Ignore the possible false return value of db2_num_rows(). - '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Connection\:\:exec\(\) should return int but returns int<0, max>\|false\.$~' - '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Result\:\:rowCount\(\) should return int but returns int<0, max>\|false\.$~' + + # This is a rather complicated closure setup. We understand this, so PHPStan doesn't have to. + - + message: '#^Parameter \#2 \$callback of function array_reduce expects callable\(\(callable&TIn\)\|Closure\(mixed \$value\)\: mixed\|null, callable\(T\)\: T\)\: \(\(callable&TIn\)\|Closure\(mixed \$value\)\: mixed\|null\), Closure\(callable\|null, callable\)\: \(callable\(T\)\: T\) given\.$#' + path: src/Portability/Converter.php + includes: - vendor/phpstan/phpstan-strict-rules/rules.neon From a0c9416b96d06032ac34e92275cee5bed3954df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 18 Jun 2024 14:12:44 +0200 Subject: [PATCH 3/4] Move schema split for SQLite CREATE INDEX only (#6352) | Q | A |------------- | ----------- | Type | bug | Fixed issues | n/a #### Summary `SqlitePlatform::getCreatePrimaryKeySQL` method must receive original table name, the split is intended for SQLite `CREATE INDEX` statement only. --- src/Platforms/SqlitePlatform.php | 10 +++---- tests/Platforms/SqlitePlatformTest.php | 36 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/Platforms/SqlitePlatform.php b/src/Platforms/SqlitePlatform.php index bbca4234db5..48c692fdb45 100644 --- a/src/Platforms/SqlitePlatform.php +++ b/src/Platforms/SqlitePlatform.php @@ -950,11 +950,6 @@ public function getCreateIndexSQL(Index $index, $table) $name = $index->getQuotedName($this); $columns = $index->getColumns(); - if (strpos($table, '.') !== false) { - [$schema, $table] = explode('.', $table); - $name = $schema . '.' . $name; - } - if (count($columns) === 0) { throw new InvalidArgumentException(sprintf( 'Incomplete or invalid index definition %s on table %s', @@ -967,6 +962,11 @@ public function getCreateIndexSQL(Index $index, $table) return $this->getCreatePrimaryKeySQL($index, $table); } + if (strpos($table, '.') !== false) { + [$schema, $table] = explode('.', $table, 2); + $name = $schema . '.' . $name; + } + $query = 'CREATE ' . $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' ON ' . $table; $query .= ' (' . $this->getIndexFieldDeclarationListSQL($index) . ')' . $this->getPartialIndexSQL($index); diff --git a/tests/Platforms/SqlitePlatformTest.php b/tests/Platforms/SqlitePlatformTest.php index f8ae9f7f6c3..8f54cf98af0 100644 --- a/tests/Platforms/SqlitePlatformTest.php +++ b/tests/Platforms/SqlitePlatformTest.php @@ -6,12 +6,17 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; +use function assert; +use function implode; +use function is_string; + /** @extends AbstractPlatformTestCase */ class SqlitePlatformTest extends AbstractPlatformTestCase { @@ -250,6 +255,37 @@ public function getGenerateUniqueIndexSql(): string return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } + public function testGeneratesIndexCreationSqlWithSchema(): void + { + $indexDef = new Index('i', ['a', 'b']); + + self::assertSame( + 'CREATE INDEX main.i ON mytable (a, b)', + $this->platform->getCreateIndexSQL($indexDef, 'main.mytable'), + ); + } + + public function testGeneratesPrimaryIndexCreationSqlWithSchema(): void + { + $primaryIndexDef = new Index('i2', ['a', 'b'], false, true); + + self::assertSame( + 'TEST: main.mytable, i2 - a, b', + (new class () extends SqlitePlatform { + /** + * {@inheritDoc} + */ + public function getCreatePrimaryKeySQL(Index $index, $table) + { + assert(is_string($table)); + + return 'TEST: ' . $table . ', ' . $index->getName() + . ' - ' . implode(', ', $index->getColumns()); + } + })->getCreateIndexSQL($primaryIndexDef, 'main.mytable'), + ); + } + public function testGeneratesForeignKeyCreationSql(): void { $this->expectException(Exception::class); From e91630dedcc0ffc2b709c16e1f099da7f495ec0b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 18 Jun 2024 14:29:05 +0200 Subject: [PATCH 4/4] PHPUnit 10.5.21 (#6447) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 800c8397ba9..2ee601aedbe 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "phpstan/phpstan": "1.11.1", "phpstan/phpstan-phpunit": "1.4.0", "phpstan/phpstan-strict-rules": "^1.6", - "phpunit/phpunit": "10.5.20", + "phpunit/phpunit": "10.5.21", "psalm/plugin-phpunit": "0.19.0", "slevomat/coding-standard": "8.13.1", "squizlabs/php_codesniffer": "3.9.2",