mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Fixing issue in DboSource with left joins on self joins
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4687 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f2c7c5a677
commit
dbbe90c22c
2 changed files with 9 additions and 2 deletions
|
@ -830,6 +830,7 @@ class DboSource extends DataSource {
|
|||
|
||||
if (!isset($queryData['selfJoin'])) {
|
||||
$queryData['selfJoin'] = array();
|
||||
|
||||
$self = array(
|
||||
'fields' => $this->fields($model, null, $queryData['fields']),
|
||||
'joins' => array(array(
|
||||
|
@ -845,6 +846,12 @@ class DboSource extends DataSource {
|
|||
'conditions'=> $queryData['conditions'],
|
||||
'order' => $queryData['order']
|
||||
);
|
||||
|
||||
if (!empty($queryData['joins'])) {
|
||||
foreach($queryData['joins'] as $join) {
|
||||
$self['joins'][] = $join;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->__bypass === false) {
|
||||
$self['fields'] = am($self['fields'], $this->fields($linkModel, $alias, ''));
|
||||
|
|
|
@ -511,8 +511,8 @@ class DboSourceTest extends UnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
$query = $this->db->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null);
|
||||
$this->assertPattern('/^SELECT\s+(.+)FROM(.+)LEFT\s+JOIN\s+`category`\s+AS\s+`ParentCat`\s+ON\s+`Category2`\.`parent_id`\s+=\s+`ParentCat`\.`id`\s+WHERE/', $query);
|
||||
$query = $this->db->generateAssociationQuery($this->model->Category2, $null, null, null, null, $queryData, false, $null);
|
||||
$this->assertPattern('/^SELECT\s+(.+)FROM(.+)`Category2`\.`group_id`\s+=\s+`Group`\.`id`\s+WHERE/', $query);
|
||||
|
||||
$this->model = new TestModel4();
|
||||
$this->model->loadInfo();
|
||||
|
|
Loading…
Add table
Reference in a new issue