diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-10-03 17:19:59 +0400 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-10-03 17:19:59 +0400 |
commit | 65c655afad78a05aa0086156c2021e37e1c86a9f (patch) | |
tree | f7a8d936738ca046955e4d1dc5fc7cc96078007a /lib | |
parent | d9ceeed60d8a5d38873dabbd4488247d90efd8a6 (diff) | |
parent | 5e0ea9f3b5a1f8315d00cd3859a7ae27283102c4 (diff) |
Merge pull request #8307 from owncloud/case_insensitive_search_oracle_stable6
on oracle use regex_like to make filename search case insensitive
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/cache/cache.php | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index e2595132557..8b289b4f7f6 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -447,9 +447,28 @@ class Cache { // normalize pattern $pattern = $this->normalize($pattern); - $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag` - FROM `*PREFIX*filecache` WHERE `name` LIKE ? AND `storage` = ?'; - $result = \OC_DB::executeAudited($sql, array($pattern, $this->getNumericStorageId())); + $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, + `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, + `unencrypted_size`, `etag` + FROM `*PREFIX*filecache` + WHERE `storage` = ? AND '; + + $dbtype = \OC_Config::getValue( 'dbtype', 'sqlite' ); + if($dbtype === 'oci') { + //replace % with .* for regex pattern + $pattern = '^'.str_replace('%', '.*', $pattern).'$'; + $sql .= 'REGEXP_LIKE(`name`, ?, \'i\')'; + } else if($dbtype === 'pgsql') { + $sql .= '`name` ILIKE ?'; + } else { + $sql .= '`name` LIKE ?'; + } + + $result = \OC_DB::executeAudited( + $sql, + array($this->getNumericStorageId(), $pattern) + ); + $files = array(); while ($row = $result->fetchRow()) { $row['mimetype'] = $this->getMimetype($row['mimetype']); |