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
|
* @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']})");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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',
|
||||||
|
|
Loading…
Reference in a new issue