Fix ILIKE without wildcards for oracle

This commit is contained in:
Robin Appelman 2014-09-18 15:09:57 +02:00
parent 0c03b2bdd5
commit a85f0ae2da
2 changed files with 5 additions and 1 deletions

View file

@ -21,7 +21,7 @@ class AdapterOCI8 extends Adapter {
const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
public function fixupStatement($statement) {
$statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, TRIM(BOTH \'%\' FROM ?), \'i\')', $statement);
$statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement);
$statement = str_replace('`', '"', $statement);
$statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
$statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);

View file

@ -282,6 +282,10 @@ class Test_DB extends PHPUnit_Framework_TestCase {
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
$result = $query->execute(array('foobar'));
$this->assertCount(1, $result->fetchAll());
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
$result = $query->execute(array('foo'));
$this->assertCount(0, $result->fetchAll());
}
public function testILIKEWildcard() {