mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Updating DboMysql to fix an issue where virtualFields that were simple
aliases to fields on other tables would end up in the wrong place. Tests added. Fixes #655
This commit is contained in:
parent
745afe888b
commit
1a7dce3af6
2 changed files with 17 additions and 2 deletions
|
@ -727,8 +727,8 @@ class DboMysql extends DboMysqlBase {
|
|||
$j = 0;
|
||||
|
||||
while ($j < $numFields) {
|
||||
$column = mysql_fetch_field($results,$j);
|
||||
if (!empty($column->table)) {
|
||||
$column = mysql_fetch_field($results, $j);
|
||||
if (!empty($column->table) && strpos($column->name, '__') === false) {
|
||||
$this->map[$index++] = array($column->table, $column->name);
|
||||
} else {
|
||||
$this->map[$index++] = array(0, $column->name);
|
||||
|
|
|
@ -7293,6 +7293,21 @@ class ModelReadTest extends BaseModelTest {
|
|||
$this->assertTrue(isset($result['Author']['full_name']));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that virtual fields work when they don't contain functions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testVirtualFieldAsAString() {
|
||||
$this->loadFixtures('Post', 'Author');
|
||||
$Post =& new Post();
|
||||
$Post->virtualFields = array(
|
||||
'writer' => 'Author.user'
|
||||
);
|
||||
$result = $Post->find('first');
|
||||
$this->assertTrue(isset($result['Post']['writer']), 'virtual field not fetched %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that isVirtualField will accept both aliased and non aliased fieldnames
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue