diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index eb5b85065..dfbded8a4 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -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; } /** diff --git a/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php b/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php new file mode 100644 index 000000000..1c40a5e43 --- /dev/null +++ b/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php @@ -0,0 +1,40 @@ + + */ +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) + ); + } +}