mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fix CROSS JOINs
While seldomly used, CROSS joins should not generate invalid SQL. Fixes #4050
This commit is contained in:
parent
e3e4efba0a
commit
6a6371b2d4
2 changed files with 11 additions and 3 deletions
|
@ -1730,8 +1730,10 @@ class DboSource extends DataSource {
|
|||
* @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 @@ class DboSourceTest extends CakeTestCase {
|
|||
*
|
||||
* @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',
|
||||
|
|
Loading…
Reference in a new issue