Project

General

Profile

Bug #21555 ยป 12596_dbal.diff

Administrator Admin, 2009-11-15 16:06

View differences:

class.ux_t3lib_sqlparser.php (working copy)
$this->lastStopKeyWord = strtoupper(str_replace(array(' ',"\t","\r","\n"), '', $this->lastStopKeyWord));
return $stack;
}
if (!preg_match('/^(LEFT|JOIN|INNER)[[:space:]]+/i', $parseString)) {
if (!preg_match('/^(LEFT|RIGHT|JOIN|INNER)[[:space:]]+/i', $parseString)) {
$stack[$pnt]['as_keyword'] = $this->nextPart($parseString,'^(AS[[:space:]]+)');
$stack[$pnt]['as'] = $this->nextPart($parseString,'^([[:alnum:]_]+)[[:space:]]*');
}
......
// Looking for JOIN
$joinCnt = 0;
while ($join = $this->nextPart($parseString,'^(LEFT[[:space:]]+JOIN|LEFT[[:space:]]+OUTER[[:space:]]+JOIN|INNER[[:space:]]+JOIN|JOIN)[[:space:]]+')) {
while ($join = $this->nextPart($parseString,'^(LEFT[[:space:]]+JOIN|LEFT[[:space:]]+OUTER[[:space:]]+JOIN|RIGHT[[:space:]]+JOIN|RIGHT[[:space:]]+OUTER[[:space:]]+JOIN|INNER[[:space:]]+JOIN|JOIN)[[:space:]]+')) {
$stack[$pnt]['JOIN'][$joinCnt]['type'] = $join;
if ($stack[$pnt]['JOIN'][$joinCnt]['withTable'] = $this->nextPart($parseString, '^([[:alnum:]_]+)[[:space:]]+', 1)) {
if (!preg_match('/^ON[[:space:]]+/i', $parseString)) {
tests/sqlparser_general_testcase.php (working copy)
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12596
*/
public function parseFromTablesWithRightOuterJoinReturnsArray() {
$parseString = 'tx_powermail_fieldsets RIGHT JOIN tt_content ON tx_powermail_fieldsets.tt_content = tt_content.uid';
$tables = $this->fixture->parseFromTables($parseString);
$this->assertTrue(is_array($tables), $tables);
$this->assertTrue(empty($parseString), 'parseString is not empty');
}
/**
* @test
*/
public function parseFromTablesWithMultipleJoinsReturnsArray() {
$parseString = 'be_users LEFT OUTER JOIN pages ON be_users.uid = pages.cruser_id INNER JOIN cache_pages cp ON cp.page_id = pages.uid';
$tables = $this->fixture->parseFromTables($parseString);
......
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12596
*/
public function parseFromTablesWithMultipleJoinsAndParenthesesReturnsArray() {
$parseString = 'tx_powermail_fieldsets RIGHT JOIN tt_content ON tx_powermail_fieldsets.tt_content = tt_content.uid LEFT JOIN tx_powermail_fields ON tx_powermail_fieldsets.uid = tx_powermail_fields.fieldset';
$tables = $this->fixture->parseFromTables($parseString);
$this->assertTrue(is_array($tables), $tables);
$this->assertTrue(empty($parseString), 'parseString is not empty');
}
/**
* @test
*/
public function parseWhereClauseReturnsArray() {
$parseString = 'uid IN (1,2) AND (starttime < ' . time() . ' OR cruser_id + 10 < 20)';
$where = $this->fixture->parseWhereClause($parseString);
    (1-1/1)