diff --git a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php index 13d283233..b533eaa18 100644 --- a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php +++ b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php @@ -24,7 +24,13 @@ namespace Doctrine\ORM\Query\AST; /** * Description of AggregateExpression * - * @author robo + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision: 3938 $ + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class AggregateExpression extends Node { diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php index 8c969cd45..fcf0b0855 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php @@ -1,7 +1,22 @@ . */ namespace Doctrine\ORM\Query\AST; @@ -9,47 +24,27 @@ namespace Doctrine\ORM\Query\AST; /** * ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")" * - * @author robo + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision: 3938 $ + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class ArithmeticExpression extends Node { - private $_simpleArithmeticExpression; - private $_subselect; - - public function setSimpleArithmeticExpression($simpleArithmeticExpr) - { - if ($this->_subselect) { - throw \Doctrine\Common\DoctrineException::updateMe(); - } - $this->_simpleArithmeticExpression = $simpleArithmeticExpr; - } - - public function setSubselect($subselect) - { - if ($this->_simpleArithmeticExpression){ - throw \Doctrine\Common\DoctrineException::updateMe(); - } - $this->_subselect = $subselect; - } - - public function getSimpleArithmeticExpression() - { - return $this->_simpleArithmeticExpression; - } - - public function getSubselect() - { - return $this->_subselect; - } + public $simpleArithmeticExpression; + public $subselect; public function isSimpleArithmeticExpression() { - return (bool) $this->_simpleArithmeticExpression; + return (bool) $this->simpleArithmeticExpression; } public function isSubselect() { - return (bool) $this->_subselect; + return (bool) $this->subselect; } public function dispatch($sqlWalker) diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index fed0757b6..04f1582c3 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -1900,14 +1900,14 @@ class Parser if ($peek['type'] === Lexer::T_SELECT) { $this->match('('); - $expr->setSubselect($this->Subselect()); + $expr->subselect = $this->Subselect(); $this->match(')'); return $expr; } } - $expr->setSimpleArithmeticExpression($this->SimpleArithmeticExpression()); + $expr->simpleArithmeticExpression = $this->SimpleArithmeticExpression(); return $expr; } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 5b5a9a5ee..77b8fc5a6 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -30,7 +30,6 @@ use Doctrine\ORM\Query, * * @author Roman Borschel * @since 2.0 - * @todo Code review for identifier quoting. * @todo Code review for schema usage with table names. * (Prepend schema name to tables IF schema is defined AND platform supports them) */ @@ -1272,17 +1271,9 @@ class SqlWalker implements TreeWalker */ public function walkArithmeticExpression($arithmeticExpr) { - $sql = ''; - - if ($arithmeticExpr->isSimpleArithmeticExpression()) { - foreach ($arithmeticExpr->getSimpleArithmeticExpression()->getArithmeticTerms() as $term) { - $sql .= $this->walkArithmeticTerm($term); - } - } else { - $sql .= $this->walkSubselect($arithmeticExpr->getSubselect()); - } - - return $sql; + return ($arithmeticExpr->isSimpleArithmeticExpression()) + ? $this->walkSimpleArithmeticExpression($arithmeticExpr->simpleArithmeticExpression) + : $this->walkSubselect($arithmeticExpr->subselect); } /**