Skip to content

Commit 6aca517

Browse files
committed
Merge branch '3.9.x' into 3.10.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 06160c8 + d5c144e commit 6aca517

File tree

9 files changed

+102
-12
lines changed

9 files changed

+102
-12
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ 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"

.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
@@ -10,6 +10,7 @@ jobs:
1010
runs-on: "ubuntu-24.04"
1111

1212
strategy:
13+
fail-fast: false
1314
matrix:
1415
php-version:
1516
- "7.4"
@@ -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/Platforms/SqlitePlatform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ public function getTemporaryTableName($tableName)
908908
*/
909909
public function canEmulateSchemas()
910910
{
911-
Deprecation::trigger(
911+
Deprecation::triggerIfCalledFromOutside(
912912
'doctrine/dbal',
913913
'https://github.com/doctrine/dbal/pull/4805',
914914
'SqlitePlatform::canEmulateSchemas() is deprecated.',

src/Schema/PostgreSQLSchemaManager.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ protected function selectTableNames(string $databaseName): Result
609609
AND table_name != 'geometry_columns'
610610
AND table_name != 'spatial_ref_sys'
611611
AND table_type = 'BASE TABLE'
612+
ORDER BY
613+
quote_ident(table_name)
612614
SQL;
613615

614616
return $this->_conn->executeQuery($sql, [$databaseName]);
@@ -695,7 +697,7 @@ protected function selectIndexColumns(string $databaseName, ?string $tableName =
695697
'c.relnamespace = n.oid',
696698
], $this->buildQueryConditions($tableName));
697699

698-
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ')';
700+
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ') ORDER BY quote_ident(ic.relname)';
699701

700702
return $this->_conn->executeQuery($sql);
701703
}
@@ -722,7 +724,7 @@ protected function selectForeignKeyColumns(string $databaseName, ?string $tableN
722724

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

725-
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ") AND r.contype = 'f'";
727+
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ") AND r.contype = 'f' ORDER BY quote_ident(r.conname)";
726728

727729
return $this->_conn->executeQuery($sql);
728730
}

src/Schema/SqliteSchemaManager.php

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

716716
if ($tableName !== null) {
717717
$conditions[] = 't.name = ?';
718-
$params[] = str_replace('.', '__', $tableName);
718+
$params[] = $this->_platform->canEmulateSchemas()
719+
? str_replace('.', '__', $tableName)
720+
: $tableName;
719721
}
720722

721723
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ' ORDER BY t.name, c.cid';
@@ -740,7 +742,9 @@ protected function selectIndexColumns(string $databaseName, ?string $tableName =
740742

741743
if ($tableName !== null) {
742744
$conditions[] = 't.name = ?';
743-
$params[] = str_replace('.', '__', $tableName);
745+
$params[] = $this->_platform->canEmulateSchemas()
746+
? str_replace('.', '__', $tableName)
747+
: $tableName;
744748
}
745749

746750
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ' ORDER BY t.name, i.seq';
@@ -766,7 +770,9 @@ protected function selectForeignKeyColumns(string $databaseName, ?string $tableN
766770

767771
if ($tableName !== null) {
768772
$conditions[] = 't.name = ?';
769-
$params[] = str_replace('.', '__', $tableName);
773+
$params[] = $this->_platform->canEmulateSchemas()
774+
? str_replace('.', '__', $tableName)
775+
: $tableName;
770776
}
771777

772778
$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
@@ -7,13 +7,15 @@
77
use Doctrine\DBAL\Platforms\SqlitePlatform;
88
use Doctrine\DBAL\Schema\Column;
99
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
10+
use Doctrine\DBAL\Schema\SqliteSchemaManager;
1011
use Doctrine\DBAL\Schema\Table;
1112
use Doctrine\DBAL\Schema\TableDiff;
1213
use Doctrine\DBAL\Types\BlobType;
1314
use Doctrine\DBAL\Types\Type;
1415
use Doctrine\DBAL\Types\Types;
1516

1617
use function array_keys;
18+
use function array_map;
1719
use function array_shift;
1820
use function assert;
1921
use function dirname;
@@ -398,6 +400,82 @@ public function testShorthandInForeignKeyReferenceWithMultipleColumns(): void
398400
);
399401
}
400402

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

0 commit comments

Comments
 (0)