1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Fix issue where paginating on a query with a subquery in the where clause crashed

This commit is contained in:
Bill Schaller 2015-03-30 10:45:41 -04:00 committed by Marco Pivetta
parent af3f5c5c5a
commit 09d28819b5

View File

@ -88,6 +88,9 @@ class LimitSubqueryOutputWalker extends SqlWalker
*/
private $orderByPathExpressions = [];
/** @var bool $inSubselect */
private $inSubselect = false;
/**
* Constructor.
*
@ -434,18 +437,6 @@ class LimitSubqueryOutputWalker extends SqlWalker
return $orderByItems;
}
/**
* {@inheritdoc}
*/
public function walkPathExpression($pathExpr)
{
if (!$this->platformSupportsRowNumber() && !in_array($pathExpr, $this->orderByPathExpressions)) {
$this->orderByPathExpressions[] = $pathExpr;
}
return parent::walkPathExpression($pathExpr);
}
/**
* getter for $orderByPathExpressions
*
@ -541,4 +532,31 @@ class LimitSubqueryOutputWalker extends SqlWalker
return $sqlIdentifier;
}
/**
* {@inheritdoc}
*/
public function walkPathExpression($pathExpr)
{
if (!$this->inSubselect && !$this->platformSupportsRowNumber() && !in_array($pathExpr, $this->orderByPathExpressions)) {
$this->orderByPathExpressions[] = $pathExpr;
}
return parent::walkPathExpression($pathExpr);
}
/**
* {@inheritdoc}
*/
public function walkSubSelect($subselect)
{
// We don't want to add path expressions from subselects into the select clause of the containing query.
$this->inSubselect = true;
$sql = parent::walkSubselect($subselect);
$this->inSubselect = false;
return $sql;
}
}