From 9e6120c86ab634c21aab09a75d1a27097031261f Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Tue, 28 May 2013 11:54:31 +0000 Subject: [PATCH] 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 --- lib/Cake/Model/Datasource/DboSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index d4c1f9802..2a75b9148 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -2494,7 +2494,7 @@ class DboSource extends DataSource { $keys = array_keys($value); if ($keys === array_values($keys)) { $count = count($value); - if ($count === 1 && !preg_match("/\s+NOT$/", $key)) { + if ($count === 1 && !preg_match('/\s+(?:NOT|\!=)$/', $key)) { $data = $this->_quoteFields($key) . ' = ('; if ($quoteValues) { if (is_object($model)) {