1
0
mirror of synced 2025-02-20 22:23:14 +03:00

Implemented multiple enhancements in InExpression support for DQL. Fixed DDC-1472 and DDC-1416.

This commit is contained in:
Guilherme Blanco 2011-12-04 02:41:54 -05:00
parent a26990c3e8
commit 0380d5ae58
4 changed files with 9 additions and 10 deletions

View File

@ -35,13 +35,13 @@ namespace Doctrine\ORM\Query\AST;
class InExpression extends Node
{
public $not;
public $pathExpression;
public $expression;
public $literals = array();
public $subselect;
public function __construct($pathExpression)
public function __construct($expression)
{
$this->pathExpression = $pathExpression;
$this->expression = $expression;
}
public function dispatch($sqlWalker)

View File

@ -2720,7 +2720,7 @@ class Parser
*/
public function InExpression()
{
$inExpression = new AST\InExpression($this->SingleValuedPathExpression());
$inExpression = new AST\InExpression($this->ArithmeticExpression());
if ($this->_lexer->isNextToken(Lexer::T_NOT)) {
$this->match(Lexer::T_NOT);

View File

@ -1727,8 +1727,7 @@ class SqlWalker implements TreeWalker
*/
public function walkInExpression($inExpr)
{
$sql = $this->walkPathExpression($inExpr->pathExpression)
. ($inExpr->not ? ' NOT' : '') . ' IN (';
$sql = $this->walkArithmeticExpression($inExpr->expression) . ($inExpr->not ? ' NOT' : '') . ' IN (';
$sql .= ($inExpr->subselect)
? $this->walkSubselect($inExpr->subselect)

View File

@ -451,8 +451,8 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
public function testSupportsSingleValuedInExpressionWithoutSpacesInWherePart()
{
$this->assertSqlGeneration(
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN(46)",
"SELECT c0_.name AS name0 FROM cms_users c0_ WHERE c0_.id IN (46)"
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE IDENTITY(u.email) IN(46)",
"SELECT c0_.name AS name0 FROM cms_users c0_ WHERE c0_.email_id IN (46)"
);
}
@ -467,8 +467,8 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
public function testSupportsNotInExpressionInWherePart()
{
$this->assertSqlGeneration(
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)',
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.id NOT IN (1)'
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :id NOT IN (1)',
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE ? NOT IN (1)'
);
}