Skip to content

Commit

Permalink
Fixing issue in DboSource::_matchRecords() where unqualified conditio…
Browse files Browse the repository at this point in the history
…ns would result in 1=1 conditions. Fixing incorrect test case. Fixes #930
  • Loading branch information
markstory committed Sep 16, 2010
1 parent 9bf6fbf commit d12d2d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions cake/libs/model/datasources/dbo_source.php
Expand Up @@ -1487,8 +1487,10 @@ function _matchRecords(&$model, $conditions = null) {
$noJoin = false;
break;
}
$conditions[$field] = $value;
unset($conditions[$originalField]);
if ($field !== $originalField) {
$conditions[$field] = $value;
unset($conditions[$originalField]);
}
}
if ($noJoin === true) {
return $this->conditions($conditions);
Expand Down
Expand Up @@ -662,13 +662,13 @@ function testAlterIndexes() {
function testUpdateAllWithNonQualifiedConditions() {
$this->loadFixtures('Article');
$Article =& new Article();
$result = $Article->updateAll(array('title' => "'Awesome'"), array('published' => 'Y'));
$result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article'));
$this->assertTrue($result);

$result = $Article->find('count', array(
'conditions' => array('Article.title' => 'Awesome')
));
$this->assertEqual($result, 3, 'Article count is wrong or fixture has changed.');
$this->assertEqual($result, 1, 'Article count is wrong or fixture has changed.');
}
}
?>
?>

0 comments on commit d12d2d7

Please sign in to comment.