Fix ILIKE without wildcards for oracle
This commit is contained in:
parent
0c03b2bdd5
commit
a85f0ae2da
2 changed files with 5 additions and 1 deletions
|
@ -21,7 +21,7 @@ class AdapterOCI8 extends Adapter {
|
||||||
const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
|
const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
|
||||||
|
|
||||||
public function fixupStatement($statement) {
|
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_replace('`', '"', $statement);
|
||||||
$statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
|
$statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
|
||||||
$statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);
|
$statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);
|
||||||
|
|
|
@ -282,6 +282,10 @@ class Test_DB extends PHPUnit_Framework_TestCase {
|
||||||
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
|
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
|
||||||
$result = $query->execute(array('foobar'));
|
$result = $query->execute(array('foobar'));
|
||||||
$this->assertCount(1, $result->fetchAll());
|
$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() {
|
public function testILIKEWildcard() {
|
||||||
|
|
Loading…
Reference in a new issue