Skip to content

Commit

Permalink
Enable SchemaManagerFunctionalTestCase::testQuotedIdentifiers() for a…
Browse files Browse the repository at this point in the history
…ll platforms
  • Loading branch information
morozov committed Feb 4, 2025
1 parent 2d52789 commit 1df0509
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions tests/Functional/Schema/SchemaManagerFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\DBAL\Schema\AbstractAsset;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
Expand Down Expand Up @@ -1261,18 +1259,6 @@ private function createReservedKeywordTables(): void
/** @throws Exception */
public function testQuotedIdentifiers(): void
{
$platform = $this->connection->getDatabasePlatform();

if ($platform instanceof DB2Platform) {
self::markTestIncomplete(
'Introspection of lower-case identifiers as quoted is currently not implemented on IBM DB2.',
);
}

if (! $platform instanceof OraclePlatform && ! $platform instanceof PostgreSQLPlatform) {
self::markTestSkipped('The current platform does not auto-quote introspected identifiers.');
}

$artists = new Table('"Artists"');
$artists->addColumn('"Id"', Types::INTEGER);
$artists->addColumn('"Name"', Types::INTEGER);
Expand All @@ -1292,17 +1278,17 @@ public function testQuotedIdentifiers(): void
);
$tracks->setPrimaryKey(['"Id"']);

$this->dropTableIfExists('"Tracks"');
$this->dropTableIfExists('"Artists"');
$platform = $this->connection->getDatabasePlatform();

$this->dropTableIfExists($tracks->getObjectName()->toSQL($platform));
$this->dropTableIfExists($artists->getObjectName()->toSQL($platform));

$this->schemaManager->createTable($artists);
$this->schemaManager->createTable($tracks);

$artists = $this->schemaManager->introspectTable('"Artists"');
$tracks = $this->schemaManager->introspectTable('"Tracks"');

$platform = $this->connection->getDatabasePlatform();

// Primary table assertions
self::assertOptionallyQualifiedNameEquals(
OptionallyQualifiedName::quoted('Artists'),
Expand All @@ -1319,11 +1305,15 @@ public function testQuotedIdentifiers(): void
$artists->getColumn('"Name"')->getObjectName(),
);

self::assertSame(['"Name"'], $artists->getIndex('"Idx_Name"')->getQuotedColumns($platform));
self::assertSame([
$platform->quoteSingleIdentifier('Name'),
], $artists->getIndex('"Idx_Name"')->getQuotedColumns($platform));

$primaryKey = $artists->getPrimaryKey();
self::assertNotNull($primaryKey);
self::assertSame(['"Id"'], $primaryKey->getQuotedColumns($platform));
self::assertSame([
$platform->quoteSingleIdentifier('Id'),
], $primaryKey->getQuotedColumns($platform));

// Foreign table assertions
self::assertUnqualifiedNameEquals(
Expand All @@ -1333,18 +1323,19 @@ public function testQuotedIdentifiers(): void

$primaryKey = $tracks->getPrimaryKey();
self::assertNotNull($primaryKey);
self::assertSame(['"Id"'], $primaryKey->getQuotedColumns($platform));
self::assertSame([
$platform->quoteSingleIdentifier('Id'),
], $primaryKey->getQuotedColumns($platform));

self::assertUnqualifiedNameEquals(
UnqualifiedName::quoted('Artist_Id'),
$tracks->getColumn('"Artist_Id"')->getObjectName(),
);

self::assertTrue($tracks->hasIndex('"Idx_Artist_Id"'));
self::assertSame(
['"Artist_Id"'],
$tracks->getIndex('"Idx_Artist_Id"')->getQuotedColumns($platform),
);
self::assertSame([
$platform->quoteSingleIdentifier('Artist_Id'),
], $tracks->getIndex('"Idx_Artist_Id"')->getQuotedColumns($platform));

$constraint = $tracks->getForeignKey('"Artists_Fk"');

Expand Down

0 comments on commit 1df0509

Please sign in to comment.