Fixed DDC-2506 by manually updating code. Closes PR #708.
This commit is contained in:
parent
dbb7c4d2bf
commit
62b4160887
@ -858,13 +858,14 @@ class SqlWalker implements TreeWalker
|
|||||||
* Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL.
|
* Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL.
|
||||||
*
|
*
|
||||||
* @param AST\JoinAssociationDeclaration $joinAssociationDeclaration
|
* @param AST\JoinAssociationDeclaration $joinAssociationDeclaration
|
||||||
* @param int $joinType
|
* @param int $joinType
|
||||||
|
* @param AST\ConditionalExpression $condExpr
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws QueryException
|
* @throws QueryException
|
||||||
*/
|
*/
|
||||||
public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joinType = AST\Join::JOIN_TYPE_INNER)
|
public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joinType = AST\Join::JOIN_TYPE_INNER, $condExpr = null)
|
||||||
{
|
{
|
||||||
$sql = '';
|
$sql = '';
|
||||||
|
|
||||||
@ -979,6 +980,13 @@ class SqlWalker implements TreeWalker
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle WITH clause
|
||||||
|
if ($condExpr !== null) {
|
||||||
|
// Phase 2 AST optimization: Skip processing of ConditionalExpression
|
||||||
|
// if only one ConditionalTerm is defined
|
||||||
|
$sql .= ' AND (' . $this->walkConditionalExpression($condExpr) . ')';
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: these should either be nested or all forced to be left joins (DDC-XXX)
|
// FIXME: these should either be nested or all forced to be left joins (DDC-XXX)
|
||||||
if ($targetClass->isInheritanceTypeJoined()) {
|
if ($targetClass->isInheritanceTypeJoined()) {
|
||||||
$sql .= $this->_generateClassTableInheritanceJoins($targetClass, $joinedDqlAlias);
|
$sql .= $this->_generateClassTableInheritanceJoins($targetClass, $joinedDqlAlias);
|
||||||
@ -1068,14 +1076,7 @@ class SqlWalker implements TreeWalker
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\JoinAssociationDeclaration):
|
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\JoinAssociationDeclaration):
|
||||||
$sql .= $this->walkJoinAssociationDeclaration($joinDeclaration, $joinType);
|
$sql .= $this->walkJoinAssociationDeclaration($joinDeclaration, $joinType, $join->conditionalExpression);
|
||||||
|
|
||||||
// Handle WITH clause
|
|
||||||
if (($condExpr = $join->conditionalExpression) !== null) {
|
|
||||||
// Phase 2 AST optimization: Skip processing of ConditionalExpression
|
|
||||||
// if only one ConditionalTerm is defined
|
|
||||||
$sql .= ' AND (' . $this->walkConditionalExpression($condExpr) . ')';
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2040,6 +2040,18 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-2506
|
||||||
|
*/
|
||||||
|
public function testClassTableInheritanceJoinWithConditionAppliesToBaseTable()
|
||||||
|
{
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
'SELECT e.id FROM Doctrine\Tests\Models\Company\CompanyOrganization o JOIN o.events e WITH e.id = ?1',
|
||||||
|
'SELECT c0_.id AS id0 FROM company_organizations c1_ INNER JOIN company_events c0_ ON c1_.id = c0_.org_id AND (c0_.id = ?) LEFT JOIN company_auctions c2_ ON c0_.id = c2_.id LEFT JOIN company_raffles c3_ ON c0_.id = c3_.id',
|
||||||
|
array(Query::HINT_FORCE_PARTIAL_LOAD => false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-1858
|
* @group DDC-1858
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user