diff --git a/src/Schema/Quoter.php b/src/Schema/Quoter.php index edc913625..d6e4d5d34 100644 --- a/src/Schema/Quoter.php +++ b/src/Schema/Quoter.php @@ -175,7 +175,7 @@ function ($matches) { public function quoteTableName(string $name): string { - if (str_starts_with($name, '(') && str_ends_with($name, ')')) { + if (str_starts_with($name, '(')) { return $name; } diff --git a/tests/Db/Schema/QuoterTest.php b/tests/Db/Schema/QuoterTest.php index a98d1dbba..ec8323913 100644 --- a/tests/Db/Schema/QuoterTest.php +++ b/tests/Db/Schema/QuoterTest.php @@ -102,4 +102,12 @@ public function testQuoteSqlWithTablePrefix(): void $this->assertSame('SELECT * FROM `prefix_table`', $quoter->quoteSql($sql)); } + + public function testQuoteTableNameWithQueryAlias() + { + $quoter = new Quoter('`', '`', 'prefix_'); + $name = '(SELECT * FROM table) alias'; + + $this->assertSame($name, $quoter->quoteTableName($name)); + } }