Skip to content
Permalink
Browse files

Fix CROSS JOINs

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

Fixes #4050
  • Loading branch information...
markstory committed Sep 5, 2013
1 parent e3e4efb commit 6a6371b2d42afb118eca5359e1bc3e2bb0e60a60
Showing with 11 additions and 3 deletions.
  1. +4 −2 lib/Cake/Model/Datasource/DboSource.php
  2. +7 −1 lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
@@ -1730,8 +1730,10 @@ public function buildStatement($query, $model) {
* @return string
*/
public function renderJoinStatement($data) {
extract($data);
return trim("{$type} JOIN {$table} {$alias} ON ({$conditions})");
if (strtoupper($data['type']) === 'CROSS') {
return "{$data['type']} JOIN {$data['table']} {$data['alias']}";
}
return trim("{$data['type']} JOIN {$data['table']} {$data['alias']} ON ({$data['conditions']})");
}
/**
@@ -1111,8 +1111,14 @@ public function testBuildStatementDefaults() {
*
* @return array
*/
public static function joinStatements($schema) {
public static function joinStatements() {
return array(
array(array(
'type' => 'CROSS',
'alias' => 'PostsTag',
'table' => 'posts_tags',
'conditions' => array('1 = 1')
), 'CROSS JOIN cakephp.posts_tags AS PostsTag'),
array(array(
'type' => 'LEFT',
'alias' => 'PostsTag',

0 comments on commit 6a6371b

Please sign in to comment.
You can’t perform that action at this time.