Project

General

Profile

Bug #22501 » 14182_dbal.diff

Administrator Admin, 2010-04-22 16:03

View differences:

class.ux_t3lib_db.php (working copy)
foreach ($v['JOIN'] as $joinCnt => $join) {
$from_table[$k]['JOIN'][$joinCnt]['withTable'] = $this->quoteName($join['withTable']);
$from_table[$k]['JOIN'][$joinCnt]['as'] = ($join['as']) ? $this->quoteName($join['as']) : '';
$from_table[$k]['JOIN'][$joinCnt]['ON'][0]['table'] = ($join['ON'][0]['table']) ? $this->quoteName($join['ON'][0]['table']) : '';
$from_table[$k]['JOIN'][$joinCnt]['ON'][0]['field'] = $this->quoteName($join['ON'][0]['field']);
$from_table[$k]['JOIN'][$joinCnt]['ON'][1]['table'] = ($join['ON'][1]['table']) ? $this->quoteName($join['ON'][1]['table']) : '';
$from_table[$k]['JOIN'][$joinCnt]['ON'][1]['field'] = $this->quoteName($join['ON'][1]['field']);
foreach ($from_table[$k]['JOIN'][$joinCnt]['ON'] as &$condition) {
$condition['left']['table'] = ($condition['left']['table']) ? $this->quoteName($condition['left']['table']) : '';
$condition['left']['field'] = $this->quoteName($condition['left']['field']);
$condition['right']['table'] = ($condition['right']['table']) ? $this->quoteName($condition['right']['table']) : '';
$condition['right']['field'] = $this->quoteName($condition['right']['field']);
}
}
}
}
......
}
$onPartsArray = array();
// Mapping ON parts of the JOIN
if (is_array($join['ON'])) {
foreach ($join['ON'] as $onParts) {
if (isset($this->mapping[$onParts['table']]['mapFieldNames'][$onParts['field']])) {
$onParts['field'] = $this->mapping[$onParts['table']]['mapFieldNames'][$onParts['field']];
if (is_array($tables[$k]['JOIN'][$joinCnt]['ON'])) {
foreach ($tables[$k]['JOIN'][$joinCnt]['ON'] as &$condition) {
// Left side of the comparator
if (isset($this->mapping[$condition['left']['table']]['mapFieldNames'][$condition['left']['field']])) {
$condition['left']['field'] = $this->mapping[$condition['left']['table']]['mapFieldNames'][$condition['left']['field']];
}
if (isset($this->mapping[$onParts['table']]['mapTableName'])) {
$onParts['table'] = $this->mapping[$onParts['table']]['mapTableName'];
if (isset($this->mapping[$condition['left']['table']]['mapTableName'])) {
$condition['left']['table'] = $this->mapping[$condition['left']['table']]['mapTableName'];
}
$onPartsArray[] = $onParts;
// Right side of the comparator
if (isset($this->mapping[$condition['right']['table']]['mapFieldNames'][$condition['right']['field']])) {
$condition['right']['field'] = $this->mapping[$condition['right']['table']]['mapFieldNames'][$condition['right']['field']];
}
if (isset($this->mapping[$condition['right']['table']]['mapTableName'])) {
$condition['right']['table'] = $this->mapping[$condition['right']['table']]['mapTableName'];
}
}
$tables[$k]['JOIN'][$joinCnt]['ON'] = $onPartsArray;
}
}
}
tests/sqlparser_general_testcase.php (working copy)
$this->assertEquals($expected, $actual);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=14182
*/
public function canParseMultipleJoinConditions() {
$sql = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.pid = T1.uid AND T2.size = 4 WHERE T1.cr_userid = 1';
$expected = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.pid=T1.uid AND T2.size=4 WHERE T1.cr_userid = 1';
$actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
$this->assertEquals($expected, $actual);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=14182
*/
public function canParseMultipleJoinConditionsWithLessThanOperator() {
$sql = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.size < 4 OR T2.pid = T1.uid WHERE T1.cr_userid = 1';
$expected = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.size<4 OR T2.pid=T1.uid WHERE T1.cr_userid = 1';
$actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
$this->assertEquals($expected, $actual);
}
///////////////////////////////////////
// Tests concerning DB management
///////////////////////////////////////
(2-2/2)