Merge branch 'feature/#1316-allow-non-public-schema-join-tables'
Close #1316
This commit is contained in:
commit
0738571b7d
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
40
tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php
Normal file
40
tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php
Normal 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;
|
||||
}
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user