mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Making DboSource::fetchAll return $this->_result if it is a boolean and $out is empty. Allows for Model::query() to return boolean values for operations that do not return recordsets. Fixes #6404
This commit is contained in:
parent
5c4bc35259
commit
5f1e6ba6a0
2 changed files with 20 additions and 1 deletions
|
@ -383,8 +383,10 @@ class DboSource extends DataSource {
|
|||
$this->_queryCache[$sql] = $out;
|
||||
}
|
||||
}
|
||||
if (empty($out) && is_bool($this->_result)) {
|
||||
return $this->_result;
|
||||
}
|
||||
return $out;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4047,6 +4047,23 @@ class DboSourceTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue