Fix CROSS JOINs

While seldomly used, CROSS joins should not generate invalid SQL.

Fixes #4050
This commit is contained in:
mark_story 2013-09-05 12:45:48 -04:00
parent e3e4efba0a
commit 6a6371b2d4
2 changed files with 11 additions and 3 deletions

View file

@ -1730,8 +1730,10 @@ class DboSource extends DataSource {
* @return string * @return string
*/ */
public function renderJoinStatement($data) { public function renderJoinStatement($data) {
extract($data); if (strtoupper($data['type']) === 'CROSS') {
return trim("{$type} JOIN {$table} {$alias} ON ({$conditions})"); return "{$data['type']} JOIN {$data['table']} {$data['alias']}";
}
return trim("{$data['type']} JOIN {$data['table']} {$data['alias']} ON ({$data['conditions']})");
} }
/** /**

View file

@ -1111,8 +1111,14 @@ class DboSourceTest extends CakeTestCase {
* *
* @return array * @return array
*/ */
public static function joinStatements($schema) { public static function joinStatements() {
return array( return array(
array(array(
'type' => 'CROSS',
'alias' => 'PostsTag',
'table' => 'posts_tags',
'conditions' => array('1 = 1')
), 'CROSS JOIN cakephp.posts_tags AS PostsTag'),
array(array( array(array(
'type' => 'LEFT', 'type' => 'LEFT',
'alias' => 'PostsTag', 'alias' => 'PostsTag',