Skip to content

Commit 5bbe026

Browse files
committed
Merge branch '3.9.x' into 4.2.x
* 3.9.x: Bump doctrine/.github from 7.2.2 to 7.3.0 (#6985) Deterministic ordering in schema manager results Nightly build tweaks Fix SQLite schema emulation in SqliteSchemaManager
2 parents c3737f8 + d5c144e commit 5bbe026

File tree

8 files changed

+95
-11
lines changed

8 files changed

+95
-11
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ on:
2525
jobs:
2626
coding-standards:
2727
name: "Coding Standards"
28-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.2.2"
28+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.3.0"
2929
with:
3030
composer-options: "--ignore-platform-req=php+"

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ on:
2424
schedule:
2525
- cron: "42 3 * * *"
2626

27-
env:
28-
fail-fast: true
29-
3027
jobs:
3128
phpunit-smoke-check:
3229
name: "PHPUnit with SQLite"

.github/workflows/documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ on:
1717
jobs:
1818
documentation:
1919
name: "Documentation"
20-
uses: "doctrine/.github/.github/workflows/documentation.yml@7.2.2"
20+
uses: "doctrine/.github/.github/workflows/documentation.yml@7.3.0"

.github/workflows/nightly.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
runs-on: "ubuntu-24.04"
1212

1313
strategy:
14+
fail-fast: false
1415
matrix:
1516
php-version:
1617
- "8.3"
@@ -80,6 +81,7 @@ jobs:
8081
dependency-versions: ${{ matrix.dependency-versions }}
8182

8283
strategy:
84+
fail-fast: false
8385
matrix:
8486
os:
8587
- ubuntu-24.04
@@ -100,6 +102,7 @@ jobs:
100102
extension: ${{ matrix.extension }}
101103

102104
strategy:
105+
fail-fast: false
103106
matrix:
104107
php-version:
105108
- '8.5'
@@ -118,6 +121,7 @@ jobs:
118121
extension: ${{ matrix.extension }}
119122

120123
strategy:
124+
fail-fast: false
121125
matrix:
122126
php-version:
123127
- '8.5'
@@ -136,6 +140,7 @@ jobs:
136140
collation: ${{ matrix.collation }}
137141

138142
strategy:
143+
fail-fast: false
139144
matrix:
140145
php-version:
141146
- '8.5'
@@ -154,6 +159,7 @@ jobs:
154159
extension: ${{ matrix.extension }}
155160

156161
strategy:
162+
fail-fast: false
157163
matrix:
158164
php-version:
159165
- '8.5'
@@ -172,6 +178,7 @@ jobs:
172178
extension: ${{ matrix.extension }}
173179

174180
strategy:
181+
fail-fast: false
175182
matrix:
176183
php-version:
177184
- '8.5'

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ on:
2525
jobs:
2626
static-analysis-phpstan:
2727
name: "Static Analysis"
28-
uses: "doctrine/.github/.github/workflows/phpstan.yml@7.2.2"
28+
uses: "doctrine/.github/.github/workflows/phpstan.yml@7.3.0"

src/Schema/PostgreSQLSchemaManager.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ protected function selectTableNames(string $databaseName): Result
409409
AND table_name != 'geometry_columns'
410410
AND table_name != 'spatial_ref_sys'
411411
AND table_type = 'BASE TABLE'
412+
ORDER BY
413+
quote_ident(table_name)
412414
SQL;
413415

414416
return $this->connection->executeQuery($sql, [$databaseName]);
@@ -509,7 +511,7 @@ protected function selectIndexColumns(string $databaseName, ?string $tableName =
509511
'c.relnamespace = n.oid',
510512
], $this->buildQueryConditions($tableName));
511513

512-
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ')';
514+
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ') ORDER BY quote_ident(ic.relname)';
513515

514516
return $this->connection->executeQuery($sql);
515517
}
@@ -536,7 +538,7 @@ protected function selectForeignKeyColumns(string $databaseName, ?string $tableN
536538

537539
$conditions = array_merge(['n.oid = c.relnamespace'], $this->buildQueryConditions($tableName));
538540

539-
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ") AND r.contype = 'f'";
541+
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ") AND r.contype = 'f' ORDER BY quote_ident(r.conname)";
540542

541543
return $this->connection->executeQuery($sql);
542544
}

src/Schema/SQLiteSchemaManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ protected function selectTableColumns(string $databaseName, ?string $tableName =
549549

550550
if ($tableName !== null) {
551551
$conditions[] = 't.name = ?';
552-
$params[] = str_replace('.', '__', $tableName);
552+
$params[] = $tableName;
553553
}
554554

555555
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ' ORDER BY t.name, c.cid';
@@ -574,7 +574,7 @@ protected function selectIndexColumns(string $databaseName, ?string $tableName =
574574

575575
if ($tableName !== null) {
576576
$conditions[] = 't.name = ?';
577-
$params[] = str_replace('.', '__', $tableName);
577+
$params[] = $tableName;
578578
}
579579

580580
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ' ORDER BY t.name, i.seq';
@@ -600,7 +600,7 @@ protected function selectForeignKeyColumns(string $databaseName, ?string $tableN
600600

601601
if ($tableName !== null) {
602602
$conditions[] = 't.name = ?';
603-
$params[] = str_replace('.', '__', $tableName);
603+
$params[] = $tableName;
604604
}
605605

606606
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ' ORDER BY t.name, p.id DESC, p.seq';

tests/Functional/Schema/SQLiteSchemaManagerTest.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
use Doctrine\DBAL\Schema\Column;
1111
use Doctrine\DBAL\Schema\ColumnDiff;
1212
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
13+
use Doctrine\DBAL\Schema\SQLiteSchemaManager;
1314
use Doctrine\DBAL\Schema\Table;
1415
use Doctrine\DBAL\Schema\TableDiff;
1516
use Doctrine\DBAL\Types\BlobType;
1617
use Doctrine\DBAL\Types\Type;
1718
use Doctrine\DBAL\Types\Types;
1819

1920
use function array_keys;
21+
use function array_map;
2022
use function array_shift;
23+
use function assert;
2124

2225
class SQLiteSchemaManagerTest extends SchemaManagerFunctionalTestCase
2326
{
@@ -393,6 +396,81 @@ public function testShorthandInForeignKeyReferenceWithMultipleColumns(): void
393396
);
394397
}
395398

399+
public function testListTableNoSchemaEmulation(): void
400+
{
401+
$databasePlatform = $this->connection->getDatabasePlatform();
402+
assert($databasePlatform instanceof SQLitePlatform);
403+
404+
$this->dropTableIfExists('`list_table_no_schema_emulation.test`');
405+
406+
$this->connection->executeStatement(<<<'DDL'
407+
CREATE TABLE `list_table_no_schema_emulation.test` (
408+
id INTEGER,
409+
parent_id INTEGER,
410+
PRIMARY KEY (id),
411+
FOREIGN KEY (parent_id) REFERENCES `list_table_no_schema_emulation.test` (id)
412+
);
413+
DDL);
414+
415+
$this->connection->executeStatement(<<<'DDL'
416+
CREATE INDEX i ON `list_table_no_schema_emulation.test` (parent_id);
417+
DDL);
418+
419+
$customSQLiteSchemaManager = new class ($this->connection, $databasePlatform) extends SQLiteSchemaManager {
420+
/** @return list<array<string, mixed>> */
421+
public function selectTableColumnsWithSchema(): array
422+
{
423+
return $this->selectTableColumns('main', 'list_table_no_schema_emulation.test')
424+
->fetchAllAssociative();
425+
}
426+
427+
/** @return list<array<string, mixed>> */
428+
public function selectIndexColumnsWithSchema(): array
429+
{
430+
return $this->selectIndexColumns('main', 'list_table_no_schema_emulation.test')
431+
->fetchAllAssociative();
432+
}
433+
434+
/** @return list<array<string, mixed>> */
435+
public function selectForeignKeyColumnsWithSchema(): array
436+
{
437+
return $this->selectForeignKeyColumns('main', 'list_table_no_schema_emulation.test')
438+
->fetchAllAssociative();
439+
}
440+
};
441+
442+
self::assertSame(
443+
[
444+
['list_table_no_schema_emulation.test', 'id'],
445+
['list_table_no_schema_emulation.test', 'parent_id'],
446+
],
447+
array_map(
448+
static fn (array $row) => [$row['table_name'], $row['name']],
449+
$customSQLiteSchemaManager->selectTableColumnsWithSchema(),
450+
),
451+
);
452+
453+
self::assertSame(
454+
[
455+
['list_table_no_schema_emulation.test', 'i'],
456+
],
457+
array_map(
458+
static fn (array $row) => [$row['table_name'], $row['name']],
459+
$customSQLiteSchemaManager->selectIndexColumnsWithSchema(),
460+
),
461+
);
462+
463+
self::assertSame(
464+
[
465+
['list_table_no_schema_emulation.test', 'parent_id', 'id'],
466+
],
467+
array_map(
468+
static fn (array $row) => [$row['table_name'], $row['from'], $row['to']],
469+
$customSQLiteSchemaManager->selectForeignKeyColumnsWithSchema(),
470+
),
471+
);
472+
}
473+
396474
/**
397475
* This test duplicates {@see parent::testCommentInTable()} with the only difference that the name of the table
398476
* being created is quoted. It is only meant to cover the logic of parsing the SQLite CREATE TABLE statement

0 commit comments

Comments
 (0)