-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Get correct expression string when Zend\Db\Sql\Expression is used #7422
Get correct expression string when Zend\Db\Sql\Expression is used #7422
Conversation
4f3f974
to
c8e85ea
Compare
@@ -108,6 +108,13 @@ protected function processExpression(ExpressionInterface $expression, PlatformIn | |||
$expressionParamIndex = &$this->instanceParameterIndex[$namedParameterPrefix]; | |||
|
|||
foreach ($parts as $part) { | |||
// #7407: use $expression->getExpression() to get the unescaped version of the expression | |||
if (is_string($part) && $expression instanceof Expression) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be it'll be better:
if (is_string($part)) {
if ($expression instanceof Expression) {
// #7407: use $expression->getExpression() to get the unescaped version of the expression
$sql .= $expression->getExpression();
} else {
// simply tack it onto the return sql "specification" string
$sql .= $part;
}
} else (is_array($part)) {
//
} else {
throw // Elements returned from getExpressionData() array must be a string or array.
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also possible, but I tried to avoid nesting if
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me It looks better then continue
and we get rid of throw
in a middle of a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When looking at different pull requests I often see the preferred way is to use continue
instead of if
/elseif
/else
structures. Personally I find the continue
easier to read, but it is all just a matter of preference.
For now I will leave it as it is, but if the ZF2 maintainers want the other structure it is no problem and I can change it at that moment.
…pression Get correct expression string when Zend\Db\Sql\Expression is used
Fix for #7407.
The processing of
Zend\Db\Sql\Expression
assumed the value of$part
was the correct value to be used, however when an instance ofZend\Db\Sql\Expression
is provided the correct value is inZend\Db\Sql\Expression::getExpression()
.