1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Merge branch 'feature/#1316-allow-non-public-schema-join-tables'

Close #1316
This commit is contained in:
Marco Pivetta 2015-03-17 23:16:26 +00:00
commit 0738571b7d
3 changed files with 87 additions and 3 deletions

View File

@ -96,9 +96,19 @@ class DefaultQuoteStrategy implements QuoteStrategy
*/
public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform)
{
return isset($association['joinTable']['quoted'])
? $platform->quoteIdentifier($association['joinTable']['name'])
: $association['joinTable']['name'];
$schema = '';
if (isset($association['joinTable']['schema'])) {
$schema = $association['joinTable']['schema'] . '.';
}
$tableName = $association['joinTable']['name'];
if (isset($association['joinTable']['quoted'])) {
$tableName = $platform->quoteIdentifier($tableName);
}
return $schema . $tableName;
}
/**

View File

@ -0,0 +1,40 @@
<?php
namespace Doctrine\Tests\Models\NonPublicSchemaJoins;
/**
* Doctrine\Tests\Models\NonPublicSchemaJoins\User
*
* @Entity
* @Table(name="readers.user")
*/
class User
{
const CLASSNAME = __CLASS__;
/**
* @Column(type="integer")
* @Id
*/
public $id;
/**
* @ManyToMany(targetEntity="Doctrine\Tests\Models\NonPublicSchemaJoins\User", inversedBy="authors")
* @JoinTable(
* name="author_reader",
* schema="readers",
* joinColumns={@JoinColumn(name="author_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="reader_id", referencedColumnName="id")}
* )
*
* @var User[]
*/
public $readers;
/**
* @ManyToMany(targetEntity="Doctrine\Tests\Models\NonPublicSchemaJoins\User", mappedBy="readers")
*
* @var User[]
*/
public $authors;
}

View File

@ -0,0 +1,34 @@
<?php
namespace Doctrine\Tests\ORM\Mapping;
use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
use Doctrine\Tests\Models\NonPublicSchemaJoins\User;
use Doctrine\Tests\OrmTestCase;
/**
* Doctrine\Tests\ORM\Mapping\DefaultQuoteStrategyTest
*
* @author Ivan Molchanov <ivan.molchanov@opensoftdev.ru>
*/
class DefaultQuoteStrategyTest extends OrmTestCase
{
/**
* @group DDC-3590
* @group 1316
*/
public function testGetJoinTableName()
{
$em = $this->_getTestEntityManager();
$metadata = $em->getClassMetadata(User::CLASSNAME);
/* @var $platform \Doctrine\DBAL\Platforms\AbstractPlatform */
$strategy = new DefaultQuoteStrategy();
$platform = $this->getMockForAbstractClass('Doctrine\DBAL\Platforms\AbstractPlatform');
$this->assertSame(
'readers.author_reader',
$strategy->getJoinTableName($metadata->associationMappings['readers'], $metadata, $platform)
);
}
}