From b895e529b25a2cdbe3d99601da7b39c20bf88ad9 Mon Sep 17 00:00:00 2001 From: Jonas Elfering Date: Tue, 15 Jul 2025 16:33:09 +0200 Subject: [PATCH 1/5] Reproduce dots in quted names --- tests/Functional/Schema/SchemaManagerTest.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/Functional/Schema/SchemaManagerTest.php b/tests/Functional/Schema/SchemaManagerTest.php index f665733135..65dbacf114 100644 --- a/tests/Functional/Schema/SchemaManagerTest.php +++ b/tests/Functional/Schema/SchemaManagerTest.php @@ -266,4 +266,61 @@ public function testIntrospectTableWithDotInName(): void self::assertCount(1, $table->getColumns()); } + + public function testIntrospectTableWithDotInIndexNames(): void + { + $table = Table::editor() + ->setQuotedName('user') + ->setColumns( + Column::editor() + ->setUnquotedName('id') + ->setTypeName(Types::INTEGER) + ->create(), + ) + ->create(); + + $this->dropAndCreateTable($table); + + $tableTo = Table::editor() + ->setUnquotedName('example') + ->setColumns( + Column::editor() + ->setUnquotedName('id') + ->setTypeName(Types::INTEGER) + ->create(), + Column::editor() + ->setUnquotedName('user_id') + ->setTypeName(Types::INTEGER) + ->create(), + ) + ->setPrimaryKeyConstraint( + PrimaryKeyConstraint::editor() + ->setUnquotedColumnNames('id') + ->setQuotedName('pk.example.id') + ->create(), + ) + ->setForeignKeyConstraints( + ForeignKeyConstraint::editor() + ->setUnquotedReferencingColumnNames('user_id') + ->setReferencedTableName($foreignTableName) + ->setUnquotedReferencedColumnNames('id') + ->setQuotedName('fk.example.user_id') + ->create(), + ) + ->setIndexes( + Index::editor() + ->setQuotedName('idx.example.id') + ->setUnquotedColumnNames('id', 'user_id') + ->create() + ) + ->create(); + $this->dropAndCreateTable($tableTo); + + + $table = $this->schemaManager->introspectTable('example'); + self::assertCount(2, $table->getColumns()); + self::assertSame('pk.example.id', $table->getPrimaryKeyConstraint()->getObjectName()->toString()); + self::assertSame('fk.example.user_id', $table->getForeignKey('fk.example.user_id')->getName()); + self::assertSame('idx.example.id', $table->getIndex('idx.example.id')->getName()); + } } From 9510d3fa4c26cc6ede0433404bad706f08fe5402 Mon Sep 17 00:00:00 2001 From: Jonas Elfering Date: Wed, 16 Jul 2025 08:23:11 +0200 Subject: [PATCH 2/5] Fix test --- tests/Functional/Schema/SchemaManagerTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/Functional/Schema/SchemaManagerTest.php b/tests/Functional/Schema/SchemaManagerTest.php index 65dbacf114..66b5f4667d 100644 --- a/tests/Functional/Schema/SchemaManagerTest.php +++ b/tests/Functional/Schema/SchemaManagerTest.php @@ -270,7 +270,7 @@ public function testIntrospectTableWithDotInName(): void public function testIntrospectTableWithDotInIndexNames(): void { $table = Table::editor() - ->setQuotedName('user') + ->setQuotedName('test_user') ->setColumns( Column::editor() ->setUnquotedName('id') @@ -302,7 +302,7 @@ public function testIntrospectTableWithDotInIndexNames(): void ->setForeignKeyConstraints( ForeignKeyConstraint::editor() ->setUnquotedReferencingColumnNames('user_id') - ->setReferencedTableName($foreignTableName) + ->setReferencedTableName('test_user') ->setUnquotedReferencedColumnNames('id') ->setQuotedName('fk.example.user_id') ->create(), @@ -311,12 +311,11 @@ public function testIntrospectTableWithDotInIndexNames(): void Index::editor() ->setQuotedName('idx.example.id') ->setUnquotedColumnNames('id', 'user_id') - ->create() + ->create(), ) ->create(); $this->dropAndCreateTable($tableTo); - $table = $this->schemaManager->introspectTable('example'); self::assertCount(2, $table->getColumns()); self::assertSame('pk.example.id', $table->getPrimaryKeyConstraint()->getObjectName()->toString()); From 43e33543f8d8846a690206222aed5c6e1cb4ea2e Mon Sep 17 00:00:00 2001 From: Jonas Elfering Date: Wed, 16 Jul 2025 08:38:29 +0200 Subject: [PATCH 3/5] Fix tests --- tests/Functional/Schema/SchemaManagerTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/Functional/Schema/SchemaManagerTest.php b/tests/Functional/Schema/SchemaManagerTest.php index 66b5f4667d..c9c22b1360 100644 --- a/tests/Functional/Schema/SchemaManagerTest.php +++ b/tests/Functional/Schema/SchemaManagerTest.php @@ -277,6 +277,11 @@ public function testIntrospectTableWithDotInIndexNames(): void ->setTypeName(Types::INTEGER) ->create(), ) + ->setPrimaryKeyConstraint( + PrimaryKeyConstraint::editor() + ->setUnquotedColumnNames('id') + ->create(), + ) ->create(); $this->dropAndCreateTable($table); @@ -296,13 +301,12 @@ public function testIntrospectTableWithDotInIndexNames(): void ->setPrimaryKeyConstraint( PrimaryKeyConstraint::editor() ->setUnquotedColumnNames('id') - ->setQuotedName('pk.example.id') ->create(), ) ->setForeignKeyConstraints( ForeignKeyConstraint::editor() ->setUnquotedReferencingColumnNames('user_id') - ->setReferencedTableName('test_user') + ->setUnquotedReferencedTableName('test_user') ->setUnquotedReferencedColumnNames('id') ->setQuotedName('fk.example.user_id') ->create(), @@ -318,7 +322,6 @@ public function testIntrospectTableWithDotInIndexNames(): void $table = $this->schemaManager->introspectTable('example'); self::assertCount(2, $table->getColumns()); - self::assertSame('pk.example.id', $table->getPrimaryKeyConstraint()->getObjectName()->toString()); self::assertSame('fk.example.user_id', $table->getForeignKey('fk.example.user_id')->getName()); self::assertSame('idx.example.id', $table->getIndex('idx.example.id')->getName()); } From 83144b1ef4ad3744eda448c0139089f7067d616b Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 4 Oct 2025 14:07:14 -0700 Subject: [PATCH 4/5] Rebase and fix tests --- tests/Functional/Schema/SchemaManagerTest.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/Functional/Schema/SchemaManagerTest.php b/tests/Functional/Schema/SchemaManagerTest.php index c9c22b1360..21b458b764 100644 --- a/tests/Functional/Schema/SchemaManagerTest.php +++ b/tests/Functional/Schema/SchemaManagerTest.php @@ -270,7 +270,7 @@ public function testIntrospectTableWithDotInName(): void public function testIntrospectTableWithDotInIndexNames(): void { $table = Table::editor() - ->setQuotedName('test_user') + ->setUnquotedName('test_user') ->setColumns( Column::editor() ->setUnquotedName('id') @@ -308,21 +308,30 @@ public function testIntrospectTableWithDotInIndexNames(): void ->setUnquotedReferencingColumnNames('user_id') ->setUnquotedReferencedTableName('test_user') ->setUnquotedReferencedColumnNames('id') - ->setQuotedName('fk.example.user_id') + ->setUnquotedName('fk.example.user_id') ->create(), ) ->setIndexes( Index::editor() - ->setQuotedName('idx.example.id') + ->setUnquotedName('idx.example.id') ->setUnquotedColumnNames('id', 'user_id') ->create(), ) ->create(); $this->dropAndCreateTable($tableTo); - $table = $this->schemaManager->introspectTable('example'); + $table = $this->schemaManager->introspectTableByUnquotedName('example'); + self::assertCount(2, $table->getColumns()); - self::assertSame('fk.example.user_id', $table->getForeignKey('fk.example.user_id')->getName()); - self::assertSame('idx.example.id', $table->getIndex('idx.example.id')->getName()); + + self::assertUnqualifiedNameEquals( + UnqualifiedName::unquoted('fk.example.user_id'), + $table->getForeignKey('"fk.example.user_id"')->getObjectName(), + ); + + self::assertUnqualifiedNameEquals( + UnqualifiedName::unquoted('idx.example.id'), + $table->getIndex('"idx.example.id"')->getObjectName(), + ); } } From 9cd18fb62f465da34059a1d816219df16697cff6 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 4 Oct 2025 14:22:46 -0700 Subject: [PATCH 5/5] Assert that the name is not null at runtime, not statically Otherwise, an extra "not null" assertion is required before comparing the value returned by OptionallyNamedObject::getObjectName() with the expected one. --- tests/FunctionalTestCase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/FunctionalTestCase.php b/tests/FunctionalTestCase.php index 51aff97921..1c88606c0c 100644 --- a/tests/FunctionalTestCase.php +++ b/tests/FunctionalTestCase.php @@ -218,8 +218,9 @@ protected function toQuotedOptionallyQualifiedName(OptionallyQualifiedName $name /** @throws Exception */ protected function assertUnqualifiedNameEquals( UnqualifiedName $expected, - UnqualifiedName $actual, + ?UnqualifiedName $actual, ): void { + self::assertNotNull($actual); self::assertEquals( $this->toQuotedUnqualifiedName($expected), $this->toQuotedUnqualifiedName($actual),