From d12d2d70cd0b25978b0f0256dba0bbfcee040248 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 16 Sep 2010 00:17:09 -0400 Subject: [PATCH] Fixing issue in DboSource::_matchRecords() where unqualified conditions would result in 1=1 conditions. Fixing incorrect test case. Fixes #930 --- cake/libs/model/datasources/dbo_source.php | 6 ++++-- .../cases/libs/model/datasources/dbo/dbo_postgres.test.php | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 2e38b960880..56646256935 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -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); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 8901cbee533..6433450309e 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -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.'); } } -?> \ No newline at end of file +?>