Skip to content

Commit 6295522

Browse files
authored
Merge pull request #46 from TheoBiron/error_with_cartesian_product
Request with cartesian product fails
2 parents a6efcac + d9a0531 commit 6295522

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/SQLParser/Node/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function toInstanceDescriptor(MoufManager $moufManager)
195195
public function toSql(array $parameters = array(), Connection $dbConnection = null, $indent = 0, $conditionsMode = self::CONDITION_APPLY)
196196
{
197197
$sql = '';
198-
if ($this->refClause) {
198+
if ($this->refClause || $this->joinType === 'CROSS JOIN') {
199199
$sql .= "\n ".$this->joinType.' ';
200200
}
201201
if ($this->database) {

tests/Mouf/Database/MagicQueryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ public function testStandardSelect()
161161

162162
$sql = 'SELECT a FROM users UNION SELECT a FROM users';
163163
$this->assertEquals('SELECT a FROM users UNION SELECT a FROM users', self::simplifySql($magicQuery->build($sql)));
164+
165+
$sql = 'SELECT a FROM users u, users u2';
166+
$this->assertEquals('SELECT a FROM users AS u CROSS JOIN users AS u2', self::simplifySql($magicQuery->build($sql)));
164167
}
165168

166169
/**

0 commit comments

Comments
 (0)