diff options
author | Thomas Citharel <tcit@tcit.fr> | 2017-09-24 15:24:08 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-09-25 09:10:44 +0200 |
commit | f1bfd4433e90f3781a82e9e8efec088f6aa77e59 (patch) | |
tree | ceec4a8c73cda52bad7200ec78dc56654316e551 /apps | |
parent | 199c4b2ff9f6bffb8d89924c7d242db074830b24 (diff) | |
download | nextcloud-server-f1bfd4433e90f3781a82e9e8efec088f6aa77e59.tar.gz nextcloud-server-f1bfd4433e90f3781a82e9e8efec088f6aa77e59.zip |
Don't add a LIKE condition when it's not needed
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 7c275611951..2e4acad6dfe 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -890,7 +890,11 @@ class CardDavBackend implements BackendInterface, SyncSupport { $or->add($query2->expr()->eq('cp.name', $query->createNamedParameter($property))); } $query2->andWhere($or); - $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%'))); + + // No need for like when the pattern is empty + if ('' !== $pattern) { + $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%'))); + } $query->select('c.carddata', 'c.uri')->from($this->dbCardsTable, 'c') ->where($query->expr()->in('c.id', $query->createFunction($query2->getSQL()))); |