Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.4.x' into 4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed May 24, 2022
2 parents 2c1fae8 + 7b85b8c commit 168939a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/Platforms/AbstractPlatform.php
Expand Up @@ -2192,17 +2192,9 @@ public function supportsReleaseSavepoints(): bool

/**
* Whether the platform supports foreign key constraints.
*
* @deprecated All platforms should support foreign key constraints.
*/
public function supportsForeignKeyConstraints(): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pulls/5409',
'AbstractPlatform::supportsForeignKeyConstraints() is deprecated.'
);

return true;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Platforms/SqlitePlatform.php
Expand Up @@ -580,6 +580,11 @@ public function getTemporaryTableName(string $tableName): string
return $tableName;
}

public function supportsForeignKeyConstraints(): bool
{
return false;
}

public function getCreatePrimaryKeySQL(Index $index, string $table): string
{
throw new Exception('Sqlite platform does not support alter primary key.');
Expand Down
24 changes: 24 additions & 0 deletions tests/Functional/Schema/SchemaManagerFunctionalTestCase.php
Expand Up @@ -445,6 +445,10 @@ public function testDropAndCreateUniqueConstraint(): void

public function testCreateTableWithForeignKeys(): void
{
if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
self::markTestSkipped('Platform does not support foreign keys.');
}

$tableB = $this->getTestTable('test_foreign');

$this->dropAndCreateTable($tableB);
Expand Down Expand Up @@ -621,6 +625,10 @@ public function testAlterTableScenario(): void
// dont check for index size here, some platforms automatically add indexes for foreign keys.
self::assertFalse($table->hasIndex('bar_idx'));

if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
return;
}

$fks = $table->getForeignKeys();
self::assertCount(1, $fks);
$foreignKey = array_shift($fks);
Expand Down Expand Up @@ -714,6 +722,12 @@ public function testAutoincrementDetectionMulticolumns(): void

public function testUpdateSchemaWithForeignKeyRenaming(): void
{
$platform = $this->connection->getDatabasePlatform();

if (! $platform->supportsForeignKeyConstraints()) {
self::markTestSkipped('This test is only supported on platforms that have foreign keys.');
}

$table = new Table('test_fk_base');
$table->addColumn('id', 'integer');
$table->setPrimaryKey(['id']);
Expand Down Expand Up @@ -759,6 +773,12 @@ public function testUpdateSchemaWithForeignKeyRenaming(): void

public function testRenameIndexUsedInForeignKeyConstraint(): void
{
$platform = $this->connection->getDatabasePlatform();

if (! $platform->supportsForeignKeyConstraints()) {
self::markTestSkipped('This test is only supported on platforms that have foreign keys.');
}

$primaryTable = new Table('test_rename_index_primary');
$primaryTable->addColumn('id', 'integer');
$primaryTable->setPrimaryKey(['id']);
Expand Down Expand Up @@ -1237,6 +1257,10 @@ public function testCommentInTable(): void

public function testCreatedCompositeForeignKeyOrderIsCorrectAfterCreation(): void
{
if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
self::markTestSkipped('Platform does not support foreign keys.');
}

$foreignKey = 'fk_test_order';
$localTable = 'test_table_foreign';
$foreignTable = 'test_table_local';
Expand Down

0 comments on commit 168939a

Please sign in to comment.