Commit 9067813e authored by Xavier Perseguers's avatar Xavier Perseguers
Browse files

[BUGFIX] SQL parser does not support string as join condition

The SQL parser is capable of parsing

    JOIN T1 ON T1.some_field = T2.some_other_field

and

    JOIN T1 ON T1.some_field = 4

but not

    JOIN T1 ON T1.some_field = 'some string'

Change-Id: I7806699ea44685ab717cc0e8a75f7b53a1b2b1cc
Resolves: #67385
Related: #66614
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/40144


Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Alexander Opitz's avatarAlexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Xavier Perseguers's avatarXavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers's avatarXavier Perseguers <xavier@typo3.org>
parent 52cc7013
......@@ -914,6 +914,8 @@ class SqlParser {
$condition['right']['table'] = '';
$condition['right']['field'] = $tableField[0];
}
} elseif ($value = $this->getValue($parseString)) {
$condition['right']['value'] = $value;
} else {
return $this->parseError('No join field found in parseFromTables()!', $parseString);
}
......@@ -1804,8 +1806,13 @@ class SqlParser {
$outputParts[$k] .= $condition['left']['table'] ? $condition['left']['table'] . '.' : '';
$outputParts[$k] .= $condition['left']['field'];
$outputParts[$k] .= $condition['comparator'];
$outputParts[$k] .= $condition['right']['table'] ? $condition['right']['table'] . '.' : '';
$outputParts[$k] .= $condition['right']['field'];
if (!empty($condition['right']['value'])) {
$value = $condition['right']['value'];
$outputParts[$k] .= $value[1] . $this->compileAddslashes($value[0]) . $value[1];
} else {
$outputParts[$k] .= $condition['right']['table'] ? $condition['right']['table'] . '.' : '';
$outputParts[$k] .= $condition['right']['field'];
}
}
}
}
......
......@@ -414,6 +414,18 @@ class SqlParserTest extends AbstractTestCase {
$this->assertEquals($expected, $this->cleanSql($result));
}
/**
* @test
* @see http://forge.typo3.org/issues/67385
*/
public function canParseMultiJoinConditionsWithStrings() {
$sql = 'SELECT * FROM sys_file_processedfile LEFT JOIN sys_registry ON entry_key = sys_file_processedfile.uid AND entry_namespace = \'ProcessedFileChecksumUpdate\'';
$result = $this->subject->debug_testSQL($sql);
$expected = 'SELECT * FROM sys_file_processedfile LEFT JOIN sys_registry ON entry_key=sys_file_processedfile.uid AND entry_namespace=\'ProcessedFileChecksumUpdate\'';
$this->assertEquals($expected, $this->cleanSql($result));
}
/**
* @test
* @see http://forge.typo3.org/issues/22501
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment