Skip to content
Permalink
Browse files

Making DboSource::fetchAll return $this->_result if it is a boolean a…

…nd $out is empty. Allows for Model::query() to return boolean values for operations that do not return recordsets. Fixes #6404
  • Loading branch information...
markstory committed Oct 30, 2009
1 parent 5c4bc35 commit 5f1e6ba6a0b671dd6b72824a612a90ec41141f7c
@@ -383,8 +383,10 @@ function fetchAll($sql, $cache = true, $modelName = null) {
$this->_queryCache[$sql] = $out;
}
}
if (empty($out) && is_bool($this->_result)) {
return $this->_result;
}
return $out;
} else {
return false;
}
@@ -4047,6 +4047,23 @@ function testExecute() {
$this->assertNotNull($this->db->took, 'Stats were not set %s');
$this->assertNotNull($this->db->affected, 'Stats were not set %s');
}
/**
* test that query() returns boolean values from operations like CREATE TABLE
*
* @return void
**/
function testFetchAllBooleanReturns() {
$name = $this->db->fullTableName('test_query');
$query = "CREATE TABLE {$name} (name varchar(10));";
$result = $this->db->query($query);
$this->assertTrue($result, 'Query did not return a boolean. %s');
$query = "DROP TABLE {$name};";
$result = $this->db->fetchAll($query);
$this->assertTrue($result, 'Query did not return a boolean. %s');
}
/**
* test ShowQuery generation of regular and error messages
*

0 comments on commit 5f1e6ba

Please sign in to comment.
You can’t perform that action at this time.