diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 24358c107..d0d3b2375 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -439,7 +439,7 @@ class Mysql extends DboSource { } $complexConditions = false; foreach ((array)$conditions as $key => $value) { - if (strpos($key, $model->alias) === false) { + if (strpos($key, '.') !== false && strpos($key, $model->alias) === false) { $complexConditions = true; break; } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index aa1353ecf..69f2898d4 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -4045,6 +4045,27 @@ SQL; $this->Dbo->delete($Article, '2=2'); } +/** + * Test deletes without complex conditions. + * + * @return void + */ + public function testDeleteNoComplexCondition() { + $this->loadFixtures('Article', 'User'); + $test = ConnectionManager::getDatasource('test'); + $db = $test->config['database']; + + $this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config)); + + $this->Dbo->expects($this->at(0))->method('execute') + ->with("DELETE `Article` FROM `$db`.`articles` AS `Article` WHERE `id` = 1"); + + $Article = new Article(); + + $conditions = array('id' => 1); + $this->Dbo->delete($Article, $conditions); + } + /** * Test truncate with a mock. *