summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/db/adapteroci8.php2
-rw-r--r--tests/lib/db.php4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/db/adapteroci8.php b/lib/private/db/adapteroci8.php
index fb4ea1bcde9..db7e66e7913 100644
--- a/lib/private/db/adapteroci8.php
+++ b/lib/private/db/adapteroci8.php
@@ -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);
diff --git a/tests/lib/db.php b/tests/lib/db.php
index d4270737d86..fb673b8092b 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -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() {