From 494bfc89661c578a987f99db5ca42fc23c102a3f Mon Sep 17 00:00:00 2001 From: Juozas Kaziukenas Date: Wed, 9 Jun 2010 15:40:54 +0100 Subject: [PATCH] Fixed length, lower, upper and mod AST functions to use platform for generating SQL --- .../ORM/Query/AST/Functions/LengthFunction.php | 5 +++-- lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php | 5 +++-- lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php | 10 ++++------ lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php | 5 +++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php index fc779e4f7..36787786d 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php @@ -41,8 +41,9 @@ class LengthFunction extends FunctionNode */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { - //TODO: Use platform to get SQL - return 'LENGTH(' . $sqlWalker->walkStringPrimary($this->stringPrimary) . ')'; + return $sqlWalker->getConnection()->getDatabasePlatform()->getLengthExpression( + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + ); } /** diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php index b5d33face..775f51d9a 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php @@ -41,8 +41,9 @@ class LowerFunction extends FunctionNode */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { - //TODO: Use platform to get SQL - return 'LOWER(' . $sqlWalker->walkStringPrimary($this->stringPrimary) . ')'; + return $sqlWalker->getConnection()->getDatabasePlatform()->getLowerExpression( + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + ); } /** diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php index 7c52d60b8..4d124fe85 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php @@ -42,12 +42,10 @@ class ModFunction extends FunctionNode */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { - //TODO: Use platform to get SQL - return 'MOD(' - . $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression) - . ', ' - . $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression) - . ')'; + return $sqlWalker->getConnection()->getDatabasePlatform()->getModExpression( + $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), + $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression) + ); } /** diff --git a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php index ff2b1e30b..acc8dd8eb 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php @@ -41,8 +41,9 @@ class UpperFunction extends FunctionNode */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { - //TODO: Use platform to get SQL - return 'UPPER(' . $sqlWalker->walkStringPrimary($this->stringPrimary) . ')'; + return $sqlWalker->getConnection()->getDatabasePlatform()->getUpperExpression( + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + ); } /**