#6464 code review updates
This commit is contained in:
parent
99fdbf550d
commit
025ed1147b
@ -872,11 +872,23 @@ class SqlWalker implements TreeWalker
|
||||
* Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL.
|
||||
*
|
||||
* @param AST\RangeVariableDeclaration $rangeVariableDeclaration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function walkRangeVariableDeclaration($rangeVariableDeclaration)
|
||||
{
|
||||
return $this->generateRangeVariableDeclarationSQL($rangeVariableDeclaration, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate appropriate SQL for RangeVariableDeclaration AST node
|
||||
*
|
||||
* @param AST\RangeVariableDeclaration $rangeVariableDeclaration
|
||||
* @param bool $buildNestedJoins
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function walkRangeVariableDeclaration($rangeVariableDeclaration, $buildNestedJoins = false)
|
||||
private function generateRangeVariableDeclarationSQL($rangeVariableDeclaration, $buildNestedJoins)
|
||||
{
|
||||
$class = $this->em->getClassMetadata($rangeVariableDeclaration->abstractSchemaName);
|
||||
$dqlAlias = $rangeVariableDeclaration->aliasIdentificationVariable;
|
||||
@ -1132,7 +1144,7 @@ class SqlWalker implements TreeWalker
|
||||
: ' INNER JOIN ';
|
||||
|
||||
switch (true) {
|
||||
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\RangeVariableDeclaration):
|
||||
case ($joinDeclaration instanceof AST\RangeVariableDeclaration):
|
||||
$class = $this->em->getClassMetadata($joinDeclaration->abstractSchemaName);
|
||||
$dqlAlias = $joinDeclaration->aliasIdentificationVariable;
|
||||
$tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias);
|
||||
@ -1142,11 +1154,12 @@ class SqlWalker implements TreeWalker
|
||||
$conditions[] = '(' . $this->walkConditionalExpression($join->conditionalExpression) . ')';
|
||||
}
|
||||
|
||||
$condExprConjunction = ($class->isInheritanceTypeJoined() && $joinType != AST\Join::JOIN_TYPE_LEFT && $joinType != AST\Join::JOIN_TYPE_LEFTOUTER && empty($conditions))
|
||||
$isUnconditionalJoin = empty($conditions);
|
||||
$condExprConjunction = ($class->isInheritanceTypeJoined() && $joinType != AST\Join::JOIN_TYPE_LEFT && $joinType != AST\Join::JOIN_TYPE_LEFTOUTER && $isUnconditionalJoin)
|
||||
? ' AND '
|
||||
: ' ON ';
|
||||
|
||||
$sql .= $this->walkRangeVariableDeclaration($joinDeclaration, !empty($conditions));
|
||||
$sql .= $this->generateRangeVariableDeclarationSQL($joinDeclaration, !$isUnconditionalJoin);
|
||||
|
||||
// Apply remaining inheritance restrictions
|
||||
$discrSql = $this->_generateDiscriminatorColumnConditionSQL([$dqlAlias]);
|
||||
@ -1168,7 +1181,7 @@ class SqlWalker implements TreeWalker
|
||||
|
||||
break;
|
||||
|
||||
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\JoinAssociationDeclaration):
|
||||
case ($joinDeclaration instanceof AST\JoinAssociationDeclaration):
|
||||
$sql .= $this->walkJoinAssociationDeclaration($joinDeclaration, $joinType, $join->conditionalExpression);
|
||||
break;
|
||||
}
|
||||
|
@ -33,10 +33,7 @@ class GH6464Test extends OrmFunctionalTestCase
|
||||
*/
|
||||
public function testIssue()
|
||||
{
|
||||
|
||||
$qb = $this->_em->createQueryBuilder();
|
||||
|
||||
$query = $qb
|
||||
$query = $this->_em->createQueryBuilder()
|
||||
->select('p', 'a')
|
||||
->from(GH6464Post::class, 'p')
|
||||
->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id')
|
||||
@ -61,12 +58,6 @@ class GH6464Post
|
||||
|
||||
/** @Column(type="integer") */
|
||||
public $authorId;
|
||||
|
||||
/** @Column(length=100) */
|
||||
public $title;
|
||||
|
||||
/** @Column(type="text") */
|
||||
public $text;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,6 +75,4 @@ abstract class GH6464User
|
||||
/** @Entity */
|
||||
class GH6464Author extends GH6464User
|
||||
{
|
||||
/** @Column(length=50) */
|
||||
public $displayName;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user