diff --git a/lib/Doctrine/ORM/Query/AST/InExpression.php b/lib/Doctrine/ORM/Query/AST/InExpression.php index 9d0a8b54e..cefb450cf 100644 --- a/lib/Doctrine/ORM/Query/AST/InExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InExpression.php @@ -45,7 +45,7 @@ class InExpression extends Node public $literals = array(); /** - * @var Subselect|null + * @var array|null */ public $subselect; diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index d5721a735..69f8b9cbe 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -109,6 +109,7 @@ class Lexer extends \Doctrine\Common\Lexer const T_WITH = 155; const T_PARTIAL = 156; const T_NEW = 157; + const T_UNION = 158; /** * Creates a new query scanner object. diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 695e7ed10..4d8ae92b6 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -3063,7 +3063,11 @@ class Parser $this->match(Lexer::T_OPEN_PARENTHESIS); if ($this->lexer->isNextToken(Lexer::T_SELECT)) { - $inExpression->subselect = $this->Subselect(); + $inExpression->subselect = [$this->Subselect()]; + while ($this->lexer->isNextToken(Lexer::T_UNION)) { + $this->match(Lexer::T_UNION); + $inExpression->subselect[] = $this->Subselect(); + } } else { $literals = array(); $literals[] = $this->InParameter(); diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 5ed7adee4..b8b5a0c32 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -2048,7 +2048,7 @@ class SqlWalker implements TreeWalker $sql = $this->walkArithmeticExpression($inExpr->expression) . ($inExpr->not ? ' NOT' : '') . ' IN ('; $sql .= ($inExpr->subselect) - ? $this->walkSubselect($inExpr->subselect) + ? implode(' UNION ', array_map(function ($subselect) {return $this->walkSubselect($subselect);}, $inExpr->subselect)) : implode(', ', array_map(array($this, 'walkInParameter'), $inExpr->literals)); $sql .= ')';