Skip to content
Permalink
Browse files

Changing the empty conditions list approach as not all drivers were h…

…appy
  • Loading branch information...
lorenzo committed Jul 25, 2014
1 parent d196633 commit de876f0f546a3181852bd3018be616fdf84cf85d
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/Database/Expression/Comparison.php
@@ -131,10 +131,17 @@ protected function _stringExpression($generator) {
$template = '%s %s (%s)';
$type = str_replace('[]', '', $this->_type);
$value = $this->_flattenValue($this->_value, $generator, $type);
// To avoid SQL erros when comparing a field to a list of empty values,
// generate a condition that will always evaluate to false
if ($value === '') {
return ['1 != 1', ''];
}
} else {
$template = '%s %s %s';
$value = $this->_bindValue($this->_value, $generator, $this->_type);
}
return [$template, $value];
}
@@ -167,10 +174,6 @@ protected function _flattenValue($value, $generator, $type = null) {
$parts[] = $this->_bindValue($v, $generator, $type);
}
if (empty($parts)) {
return "SELECT CAST(NULL as $type)";
}
return implode(',', $parts);
}

0 comments on commit de876f0

Please sign in to comment.
You can’t perform that action at this time.