Project

General

Profile

Bug #22716 » 14479_v2.diff

Administrator Admin, 2010-05-27 23:21

View differences:

class.ux_t3lib_sqlparser.php (working copy)
} else {
$compareValue = $v['value'][1] . $this->compileAddslashes(trim($v['value'][0], '%')) . $v['value'][1];
}
$output .= '(dbms_lob.instr(' . trim(($v['table'] ? $v['table'] . '.' : '') . $v['field']) . ', ' . $compareValue . ',1,1) > 0)';
// To be on the safe side
$isLob = TRUE;
if ($v['table']) {
// Table and field names are quoted:
$tableName = substr($v['table'], 1, strlen($v['table']) - 2);
$fieldName = substr($v['field'], 1, strlen($v['field']) - 2);
$fieldType = $GLOBALS['TYPO3_DB']->sql_field_metatype($tableName, $fieldName);
$isLob = ($fieldType === 'B' || $fieldType === 'XL');
}
if ($isLob) {
$output .= '(dbms_lob.instr(' . trim(($v['table'] ? $v['table'] . '.' : '') . $v['field']) . ', ' . $compareValue . ',1,1) > 0)';
} else {
$output .= '(instr(' . trim(($v['table'] ? $v['table'] . '.' : '') . $v['field']) . ', ' . $compareValue . ',1,1) > 0)';
}
break;
default:
$output .= ' ' . $v['comparator'];
tests/db_oracle_testcase.php (working copy)
. ' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)'
));
$expected = 'SELECT * FROM "sys_refindex", "tx_dam_file_tracking" WHERE "sys_refindex"."tablename" = \'tx_dam_file_tracking\'';
$expected .= ' AND (dbms_lob.instr("sys_refindex"."ref_string", CONCAT("tx_dam_file_tracking"."file_path","tx_dam_file_tracking"."file_name"),1,1) > 0)';
$expected .= ' AND (instr("sys_refindex"."ref_string", CONCAT("tx_dam_file_tracking"."file_path","tx_dam_file_tracking"."file_name"),1,1) > 0)';
$this->assertEquals($expected, $query);
}
......
$query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery($selectFields, $fromTables, $whereClause, $groupBy, $orderBy));
$expected = 'SELECT * FROM "sys_refindex", "tx_dam_file_tracking" WHERE "sys_refindex"."tablename" = \'tx_dam_file_tracking\'';
$expected .= ' AND (dbms_lob.instr("sys_refindex"."ref_string", CONCAT("tx_dam_file_tracking"."path","tx_dam_file_tracking"."filename"),1,1) > 0)';
$expected .= ' AND (instr("sys_refindex"."ref_string", CONCAT("tx_dam_file_tracking"."path","tx_dam_file_tracking"."filename"),1,1) > 0)';
$this->assertEquals($expected, $query);
}
......
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=14479
*/
public function likeIsRemappedAccordingToFieldType() {
$select = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_content',
'tt_content.bodytext LIKE \'foo%\''
));
$expected = 'SELECT * FROM "tt_content" WHERE (dbms_lob.instr("tt_content"."bodytext", \'foo\',1,1) > 0)';
$this->assertEquals($expected, $select);
$select = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'fe_group',
'fe_group.subgroup LIKE \'2\''
));
$expected = 'SELECT * FROM "fe_group" WHERE (instr("fe_group"."subgroup", \'2\',1,1) > 0)';
$this->assertEquals($expected, $select);
}
///////////////////////////////////////
// Tests concerning DB management
///////////////////////////////////////
(2-2/3)