Skip to content

Changing the CASE EXPRESSION to support STRINGS as returned values. #278

Closed
wants to merge 1 commit into from
View
21 lib/Doctrine/ORM/Query/SqlWalker.php
@@ -2147,4 +2147,25 @@ public function walkResultVariable($resultVariable)
return $resultAlias;
}
+
+ /**
+ * It was made to be used to return strings
+ *
+ * @param GeneralCaseExpression $generalCaseExpression
+ * @return string The SQL.
+ * @author Renato Medina [medinadato@gmail.com]
+ */
+ public function walkGeneralStringCaseExpression(AST\GeneralCaseExpression $generalCaseExpression)
+ {
+ $sql = 'CASE';
+
+ foreach ($generalCaseExpression->whenClauses as $whenClause) {
+ $sql .= ' WHEN ' . $this->walkConditionalExpression($whenClause->caseConditionExpression);
+ $sql .= ' THEN \'' . $this->walkSimpleArithmeticExpression($whenClause->thenScalarExpression) . '\'';
+ }
+
+ $sql .= ' ELSE \'' . $this->walkSimpleArithmeticExpression($generalCaseExpression->elseScalarExpression) . '\' END';
+
+ return $sql;
+ }
}
Something went wrong with that request. Please try again.