-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The current behavior is that a quote in the table name should result in the name being considered "quoted" and be passed to DBAL's quoteIdentifier() method, which should quote each identifier individually (so the dot is still interpreted as a schema separator).
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
tests/Tests/ORM/Functional/Mapping/PostgreSqlDefaultQuoteStrategyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Mapping; | ||
|
||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\ORM\Mapping\Driver\AttributeDriver; | ||
use Doctrine\ORM\Tools\SchemaTool; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
class PostgreSqlDefaultQuoteStrategyTest extends OrmFunctionalTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$platform = $this->_em->getConnection()->getDatabasePlatform(); | ||
if (! $platform instanceof PostgreSQLPlatform) { | ||
self::markTestSkipped(self::class . ' requires the use of postgresql.'); | ||
} | ||
|
||
$this->_em = $this->getEntityManager( | ||
null, | ||
new AttributeDriver([__DIR__], true) | ||
); | ||
$this->_schemaTool = new SchemaTool($this->_em); | ||
} | ||
|
||
public function testQuotingStillAllowsInterpretingDotAsSchemaSeparator(): void | ||
{ | ||
$this->createSchemaForModels(Product::class); | ||
$schemaManager = $this->createSchemaManager(); | ||
self::assertContains( | ||
'Inventory', | ||
$schemaManager->listSchemaNames(), | ||
'"Inventory" should be interpreted as a schema name, even when quoted.' | ||
); | ||
self::assertContains( | ||
'Products', | ||
$schemaManager->listTableNames(), | ||
'"Products" should be interpreted as a table name, even when quoted.' | ||
); | ||
} | ||
} | ||
|
||
#[ORM\Entity] | ||
#[ORM\Table(name: '"Inventory.Products"')] // Using quotes to make sure capitalization is preserved | ||
class Product | ||
{ | ||
#[ORM\Id] | ||
public ?int $id = null; | ||
} |