Skip to content

Commit 33ce3c4

Browse files
committed
Merge branch '3.8.x' into 3.9.x
* 3.8.x: Move schema split for SQLite CREATE INDEX only (doctrine#6352) PHPStan 1.11.5 (doctrine#6446) Revert "Merge pull request doctrine#6413 from achterin/bugfix/foreign_key_name_change_detection" CI: Update MariaDB versions (doctrine#6426) CI MariaDB: add 11.4, remove 11.0 (doctrine#6432) Fix typo in the portability documentation (doctrine#6430)
2 parents df1bd13 + a0c9416 commit 33ce3c4

File tree

8 files changed

+59
-22
lines changed

8 files changed

+59
-22
lines changed

.github/workflows/continuous-integration.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ jobs:
302302
- "10.5" # LTS (Jun 2025)
303303
- "10.6" # LTS (Jul 2026)
304304
- "10.11" # LTS (Feb 2028)
305-
- "11.0" # STS (Jun 2024)
306305
- "11.1" # STS (Aug 2024)
307306
- "11.2" # STS (Nov 2024)
308307
- "11.3" # STS (Feb 2025)
308+
- "11.4" # LTS (May 2029)
309309
extension:
310310
- "mysqli"
311311
- "pdo_mysql"
@@ -317,16 +317,16 @@ jobs:
317317
mariadb-version: "10.6"
318318
extension: "pdo_mysql"
319319
- php-version: "8.2"
320-
mariadb-version: "11.2"
320+
mariadb-version: "11.4"
321321
extension: "mysqli"
322322
- php-version: "8.2"
323-
mariadb-version: "11.2"
323+
mariadb-version: "11.4"
324324
extension: "pdo_mysql"
325325
- php-version: "8.3"
326-
mariadb-version: "11.2"
326+
mariadb-version: "11.4"
327327
extension: "mysqli"
328328
- php-version: "8.3"
329-
mariadb-version: "11.2"
329+
mariadb-version: "11.4"
330330
extension: "pdo_mysql"
331331

332332
services:
@@ -337,7 +337,7 @@ jobs:
337337
MYSQL_DATABASE: "doctrine_tests"
338338

339339
options: >-
340-
--health-cmd "mariadb-admin ping --silent || mysqladmin ping --silent"
340+
--health-cmd "healthcheck.sh --connect --innodb_initialized || mysqladmin ping --protocol tcp --silent"
341341
342342
ports:
343343
- "3306:3306"

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"doctrine/coding-standard": "12.0.0",
4444
"fig/log-test": "^1",
4545
"jetbrains/phpstorm-stubs": "2023.1",
46-
"phpstan/phpstan": "1.11.1",
46+
"phpstan/phpstan": "1.11.5",
4747
"phpstan/phpstan-strict-rules": "^1.6",
4848
"phpunit/phpunit": "9.6.19",
4949
"psalm/plugin-phpunit": "0.18.4",

docs/en/reference/portability.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Using the following code block in your initialization will:
5353
use Doctrine\DBAL\ColumnCase;
5454
use Doctrine\DBAL\Configuration;
5555
use Doctrine\DBAL\Portability\Connection as PortableConnection;
56-
use Doctrine\DBAL\Portability\Middleware as PotableMiddleware;
56+
use Doctrine\DBAL\Portability\Middleware as PortableMiddleware;
5757
5858
$configuration = new Configuration();
5959
$configuration->setMiddlewares([

phpstan.neon.dist

+6
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,11 @@ parameters:
146146
# Ignore the possible false return value of db2_num_rows().
147147
- '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Connection\:\:exec\(\) should return int but returns int<0, max>\|false\.$~'
148148
- '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Result\:\:rowCount\(\) should return int but returns int<0, max>\|false\.$~'
149+
150+
# This is a rather complicated closure setup. We understand this, so PHPStan doesn't have to.
151+
-
152+
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\.$#'
153+
path: src/Portability/Converter.php
154+
149155
includes:
150156
- vendor/phpstan/phpstan-strict-rules/rules.neon

src/Platforms/SqlitePlatform.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -950,11 +950,6 @@ public function getCreateIndexSQL(Index $index, $table)
950950
$name = $index->getQuotedName($this);
951951
$columns = $index->getColumns();
952952

953-
if (strpos($table, '.') !== false) {
954-
[$schema, $table] = explode('.', $table);
955-
$name = $schema . '.' . $name;
956-
}
957-
958953
if (count($columns) === 0) {
959954
throw new InvalidArgumentException(sprintf(
960955
'Incomplete or invalid index definition %s on table %s',
@@ -967,6 +962,11 @@ public function getCreateIndexSQL(Index $index, $table)
967962
return $this->getCreatePrimaryKeySQL($index, $table);
968963
}
969964

965+
if (strpos($table, '.') !== false) {
966+
[$schema, $table] = explode('.', $table, 2);
967+
$name = $schema . '.' . $name;
968+
}
969+
970970
$query = 'CREATE ' . $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' ON ' . $table;
971971
$query .= ' (' . $this->getIndexFieldDeclarationListSQL($index) . ')' . $this->getPartialIndexSQL($index);
972972

src/Schema/Comparator.php

-4
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,6 @@ private function detectRenamedIndexes(array &$addedIndexes, array &$removedIndex
555555
*/
556556
public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2)
557557
{
558-
if (strtolower($key1->getName()) !== strtolower($key2->getName())) {
559-
return true;
560-
}
561-
562558
if (
563559
array_map('strtolower', $key1->getUnquotedLocalColumns())
564560
!== array_map('strtolower', $key2->getUnquotedLocalColumns())

tests/Platforms/SqlitePlatformTest.php

+36
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
use Doctrine\DBAL\Platforms\AbstractPlatform;
77
use Doctrine\DBAL\Platforms\SqlitePlatform;
88
use Doctrine\DBAL\Schema\Column;
9+
use Doctrine\DBAL\Schema\Index;
910
use Doctrine\DBAL\Schema\Table;
1011
use Doctrine\DBAL\Schema\TableDiff;
1112
use Doctrine\DBAL\TransactionIsolationLevel;
1213
use Doctrine\DBAL\Types\Type;
1314
use Doctrine\DBAL\Types\Types;
1415

16+
use function assert;
17+
use function implode;
18+
use function is_string;
19+
1520
/** @extends AbstractPlatformTestCase<SqlitePlatform> */
1621
class SqlitePlatformTest extends AbstractPlatformTestCase
1722
{
@@ -250,6 +255,37 @@ public function getGenerateUniqueIndexSql(): string
250255
return 'CREATE UNIQUE INDEX index_name ON test (test, test2)';
251256
}
252257

258+
public function testGeneratesIndexCreationSqlWithSchema(): void
259+
{
260+
$indexDef = new Index('i', ['a', 'b']);
261+
262+
self::assertSame(
263+
'CREATE INDEX main.i ON mytable (a, b)',
264+
$this->platform->getCreateIndexSQL($indexDef, 'main.mytable'),
265+
);
266+
}
267+
268+
public function testGeneratesPrimaryIndexCreationSqlWithSchema(): void
269+
{
270+
$primaryIndexDef = new Index('i2', ['a', 'b'], false, true);
271+
272+
self::assertSame(
273+
'TEST: main.mytable, i2 - a, b',
274+
(new class () extends SqlitePlatform {
275+
/**
276+
* {@inheritDoc}
277+
*/
278+
public function getCreatePrimaryKeySQL(Index $index, $table)
279+
{
280+
assert(is_string($table));
281+
282+
return 'TEST: ' . $table . ', ' . $index->getName()
283+
. ' - ' . implode(', ', $index->getColumns());
284+
}
285+
})->getCreateIndexSQL($primaryIndexDef, 'main.mytable'),
286+
);
287+
}
288+
253289
public function testGeneratesForeignKeyCreationSql(): void
254290
{
255291
$this->expectException(Exception::class);

tests/Schema/AbstractComparatorTestCase.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ public function testCompareColumnCompareCaseInsensitive(): void
652652
self::assertFalse($tableDiff);
653653
}
654654

655-
public function testDetectIndexNameChange(): void
655+
public function testCompareIndexBasedOnPropertiesNotName(): void
656656
{
657657
$tableA = new Table('foo');
658658
$tableA->addColumn('id', Types::INTEGER);
@@ -672,7 +672,7 @@ public function testDetectIndexNameChange(): void
672672
);
673673
}
674674

675-
public function testDetectForeignKeyNameChange(): void
675+
public function testCompareForeignKeyBasedOnPropertiesNotName(): void
676676
{
677677
$tableA = new Table('foo');
678678
$tableA->addColumn('id', Types::INTEGER);
@@ -683,9 +683,8 @@ public function testDetectForeignKeyNameChange(): void
683683
$tableB->addForeignKeyConstraint('bar', ['id'], ['id'], [], 'bar_constraint');
684684

685685
$tableDiff = $this->comparator->diffTable($tableA, $tableB);
686-
self::assertNotFalse($tableDiff);
687-
self::assertCount(1, $tableDiff->addedForeignKeys);
688-
self::assertCount(1, $tableDiff->removedForeignKeys);
686+
687+
self::assertFalse($tableDiff);
689688
}
690689

691690
public function testCompareForeignKeyRestrictNoActionAreTheSame(): void

0 commit comments

Comments
 (0)