#6464 code review updates
This commit is contained in:
parent
bf1188127e
commit
9e6f061bfb
@ -866,11 +866,23 @@ class SqlWalker implements TreeWalker
|
|||||||
* Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL.
|
* Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL.
|
||||||
*
|
*
|
||||||
* @param AST\RangeVariableDeclaration $rangeVariableDeclaration
|
* @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
|
* @param bool $buildNestedJoins
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function walkRangeVariableDeclaration($rangeVariableDeclaration, $buildNestedJoins = false)
|
private function generateRangeVariableDeclarationSQL($rangeVariableDeclaration, $buildNestedJoins)
|
||||||
{
|
{
|
||||||
$class = $this->em->getClassMetadata($rangeVariableDeclaration->abstractSchemaName);
|
$class = $this->em->getClassMetadata($rangeVariableDeclaration->abstractSchemaName);
|
||||||
$dqlAlias = $rangeVariableDeclaration->aliasIdentificationVariable;
|
$dqlAlias = $rangeVariableDeclaration->aliasIdentificationVariable;
|
||||||
@ -1126,16 +1138,17 @@ class SqlWalker implements TreeWalker
|
|||||||
: ' INNER JOIN ';
|
: ' INNER JOIN ';
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\RangeVariableDeclaration):
|
case ($joinDeclaration instanceof AST\RangeVariableDeclaration):
|
||||||
$class = $this->em->getClassMetadata($joinDeclaration->abstractSchemaName);
|
$class = $this->em->getClassMetadata($joinDeclaration->abstractSchemaName);
|
||||||
$dqlAlias = $joinDeclaration->aliasIdentificationVariable;
|
$dqlAlias = $joinDeclaration->aliasIdentificationVariable;
|
||||||
$tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias);
|
$tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias);
|
||||||
$condition = '(' . $this->walkConditionalExpression($join->conditionalExpression) . ')';
|
$condition = '(' . $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 '
|
? ' AND '
|
||||||
: ' ON ';
|
: ' ON ';
|
||||||
|
|
||||||
$sql .= $this->walkRangeVariableDeclaration($joinDeclaration, !empty($conditions));
|
$sql .= $this->generateRangeVariableDeclarationSQL($joinDeclaration, !$isUnconditionalJoin);
|
||||||
|
|
||||||
$conditions = array($condition);
|
$conditions = array($condition);
|
||||||
|
|
||||||
@ -1156,7 +1169,7 @@ class SqlWalker implements TreeWalker
|
|||||||
$sql .= $condExprConjunction . implode(' AND ', $conditions);
|
$sql .= $condExprConjunction . implode(' AND ', $conditions);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\JoinAssociationDeclaration):
|
case ($joinDeclaration instanceof AST\JoinAssociationDeclaration):
|
||||||
$sql .= $this->walkJoinAssociationDeclaration($joinDeclaration, $joinType, $join->conditionalExpression);
|
$sql .= $this->walkJoinAssociationDeclaration($joinDeclaration, $joinType, $join->conditionalExpression);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,7 @@ class GH6464Test extends OrmFunctionalTestCase
|
|||||||
*/
|
*/
|
||||||
public function testIssue()
|
public function testIssue()
|
||||||
{
|
{
|
||||||
|
$query = $this->_em->createQueryBuilder()
|
||||||
$qb = $this->_em->createQueryBuilder();
|
|
||||||
|
|
||||||
$query = $qb
|
|
||||||
->select('p', 'a')
|
->select('p', 'a')
|
||||||
->from(GH6464Post::class, 'p')
|
->from(GH6464Post::class, 'p')
|
||||||
->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id')
|
->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id')
|
||||||
@ -61,12 +58,6 @@ class GH6464Post
|
|||||||
|
|
||||||
/** @Column(type="integer") */
|
/** @Column(type="integer") */
|
||||||
public $authorId;
|
public $authorId;
|
||||||
|
|
||||||
/** @Column(length=100) */
|
|
||||||
public $title;
|
|
||||||
|
|
||||||
/** @Column(type="text") */
|
|
||||||
public $text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,6 +75,4 @@ abstract class GH6464User
|
|||||||
/** @Entity */
|
/** @Entity */
|
||||||
class GH6464Author extends GH6464User
|
class GH6464Author extends GH6464User
|
||||||
{
|
{
|
||||||
/** @Column(length=50) */
|
|
||||||
public $displayName;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user