From ed432fbc50d0d676bcd1313a27b4faa93abce051 Mon Sep 17 00:00:00 2001 From: Tom Lingham Date: Sat, 14 May 2016 11:31:15 +1000 Subject: [PATCH] Coalesce NULL fields to empty string for the purposes of running the search. Fixed #23 --- src/SearchDrivers/BaseSearchDriver.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SearchDrivers/BaseSearchDriver.php b/src/SearchDrivers/BaseSearchDriver.php index d4f5557..926b440 100755 --- a/src/SearchDrivers/BaseSearchDriver.php +++ b/src/SearchDrivers/BaseSearchDriver.php @@ -193,6 +193,11 @@ abstract class BaseSearchDriver implements SearchDriverInterface { $matcher = new $matcherClass($multiplier); - return $matcher->buildQueryString($searchField, $this->searchString); + return $matcher->buildQueryString($this->coalesce($searchField), $this->searchString); + } + + private function coalesce($field) + { + return "COALESCE($field, '')"; } }