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:
nate 2007-03-27 01:59:39 +00:00
parent f2c7c5a677
commit dbbe90c22c
2 changed files with 9 additions and 2 deletions

View file

@ -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, ''));

View file

@ -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();