Project

General

Profile

Bug #21514 » 12535_dbal_v3.diff

Administrator Admin, 2010-07-27 21:42

View differences:

class.ux_t3lib_sqlparser.php (working copy)
} else {
$output .= $v['calc_value'][1] . $this->compileAddslashes($v['calc_value'][0]) . $v['calc_value'][1];
}
} elseif (!($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $v['comparator'] === 'LIKE' && $functionMapping)) {
} elseif (!($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && preg_match('/(NOT )?LIKE( BINARY)?/', $v['comparator']) && $functionMapping)) {
$output .= trim(($v['table'] ? $v['table'] . '.' : '') . $v['field']);
}
}
// Set comparator:
if ($v['comparator']) {
$isLikeOperator = preg_match('/(NOT )?LIKE( BINARY)?/', $v['comparator']);
switch (TRUE) {
case ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $v['comparator'] === 'LIKE' && $functionMapping):
case ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') && $isLikeOperator && $functionMapping):
// Oracle cannot handle LIKE on CLOB fields - sigh
if (isset($v['value']['operator'])) {
$values = array();
......
} else {
$compareValue = $v['value'][1] . $this->compileAddslashes(trim($v['value'][0], '%')) . $v['value'][1];
}
if (t3lib_div::isFirstPartOfStr($v['comparator'], 'NOT')) {
$output .= 'NOT ';
}
// To be on the safe side
$isLob = TRUE;
if ($v['table']) {
......
}
break;
default:
if ($isLikeOperator && $functionMapping) {
if ($GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres') ||
$GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres64') ||
$GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres7') ||
$GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres8')) {
// Remap (NOT)? LIKE to (NOT)? ILIKE
// and (NOT)? LIKE BINARY to (NOT)? LIKE
switch ($v['comparator']) {
// Remap (NOT)? LIKE to (NOT)? ILIKE
case 'LIKE':
$v['comparator'] = 'ILIKE';
break;
case 'NOT LIKE':
$v['comparator'] = 'NOT ILIKE';
break;
default:
$v['comparator'] = str_replace(' BINARY', '', $v['comparator']);
break;
}
} else {
// No more BINARY operator
$v['comparator'] = str_replace(' BINARY', '', $v['comparator']);
}
}
$output .= ' ' . $v['comparator'];
// Detecting value type; list or plain:
tests/dbPostgresqlTest.php (working copy)
$expected = 'SELECT * FROM "fe_users" WHERE FIND_IN_SET(10, "usergroup") != 0';
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12535
*/
public function likeBinaryOperatorIsRemappedToLike() {
$query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_content',
'bodytext LIKE BINARY \'test\''
));
$expected = 'SELECT * FROM "tt_content" WHERE "bodytext" LIKE \'test\'';
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12535
*/
public function notLikeBinaryOperatorIsRemappedToNotLike() {
$query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_content',
'bodytext NOT LIKE BINARY \'test\''
));
$expected = 'SELECT * FROM "tt_content" WHERE "bodytext" NOT LIKE \'test\'';
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12535
*/
public function likeOperatorIsRemappedToIlike() {
$query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_content',
'bodytext LIKE \'test\''
));
$expected = 'SELECT * FROM "tt_content" WHERE "bodytext" ILIKE \'test\'';
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12535
*/
public function notLikeOperatorIsRemappedToNotIlike() {
$query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_content',
'bodytext NOT LIKE \'test\''
));
$expected = 'SELECT * FROM "tt_content" WHERE "bodytext" NOT ILIKE \'test\'';
$this->assertEquals($expected, $query);
}
}
?>
tests/dbOracleTest.php (working copy)
$expected = 'SELECT * FROM "fe_users" WHERE \',\'||"usergroup"||\',\' LIKE \'%,10,%\'';
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12535
*/
public function likeBinaryOperatorIsRemoved() {
$query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_content',
'bodytext LIKE BINARY \'test\''
));
$expected = 'SELECT * FROM "tt_content" WHERE (dbms_lob.instr("bodytext", \'test\',1,1) > 0)';
$this->assertEquals($expected, $query);
}
}
?>
tests/dbGeneralTest.php (working copy)
$expected = 'SELECT * FROM pages WHERE MAX(uid) IN (1,2,3,4)';
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12535
*/
public function likeBinaryOperatorIsKept() {
$query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_content',
'bodytext LIKE BINARY \'test\''
));
$expected = 'SELECT * FROM tt_content WHERE bodytext LIKE BINARY \'test\'';
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=12535
*/
public function notLikeBinaryOperatorIsKept() {
$query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_content',
'bodytext NOT LIKE BINARY \'test\''
));
$expected = 'SELECT * FROM tt_content WHERE bodytext NOT LIKE BINARY \'test\'';
$this->assertEquals($expected, $query);
}
}
?>
(3-3/4)