This fixes an issue where attempting to use "!=" in a condition with an array with only a single element generates invalid SQL.

Example:
$condition['Model.id !='] = array(1, 2); //Generates Model.id NOT IN (1, 2) as expected
$condition['Model.id !='] = array(1); //Generates Model.id != = (1) which is invalid SQL

Patch will cause the above to generate Model.id != (1);

This an implimentation of @markstory's suggestion on PR 1232
This commit is contained in:
Christian Winther 2013-05-28 11:54:31 +00:00
parent fb86859585
commit 9e6120c86a

View file

@ -2494,7 +2494,7 @@ class DboSource extends DataSource {
$keys = array_keys($value); $keys = array_keys($value);
if ($keys === array_values($keys)) { if ($keys === array_values($keys)) {
$count = count($value); $count = count($value);
if ($count === 1 && !preg_match("/\s+NOT$/", $key)) { if ($count === 1 && !preg_match('/\s+(?:NOT|\!=)$/', $key)) {
$data = $this->_quoteFields($key) . ' = ('; $data = $this->_quoteFields($key) . ' = (';
if ($quoteValues) { if ($quoteValues) {
if (is_object($model)) { if (is_object($model)) {