diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 5aed9c991..1a894b55b 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -1865,7 +1865,7 @@ class DboSource extends DataSource { 'type' => null, 'alias' => null, 'table' => 'join_table', - 'conditions' => array() + 'conditions' => '', ), $join); if (!empty($data['alias'])) { @@ -1919,7 +1919,7 @@ class DboSource extends DataSource { * @return string */ public function renderJoinStatement($data) { - if (strtoupper($data['type']) === 'CROSS') { + if (strtoupper($data['type']) === 'CROSS' || empty($data['conditions'])) { return "{$data['type']} JOIN {$data['table']} {$data['alias']}"; } return trim("{$data['type']} JOIN {$data['table']} {$data['alias']} ON ({$data['conditions']})"); diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index 562e314d9..25439c8ef 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -1197,6 +1197,11 @@ class DboSourceTest extends CakeTestCase { 'table' => 'posts_tags', 'conditions' => array('1 = 1') ), 'CROSS JOIN cakephp.posts_tags AS PostsTag'), + array(array( + 'type' => 'LEFT', + 'alias' => 'PostsTag', + 'table' => 'posts_tags', + ), 'LEFT JOIN cakephp.posts_tags AS PostsTag'), array(array( 'type' => 'LEFT', 'alias' => 'PostsTag',