diff --git a/search/SearchContext.php b/search/SearchContext.php index 946d36108..817db85d1 100644 --- a/search/SearchContext.php +++ b/search/SearchContext.php @@ -108,7 +108,7 @@ class SearchContext extends Object { if($existingQuery) { $query = $existingQuery; } else { - $query = $model->extendedSQL(); + $query = $model->buildSQL(); } $SQL_limit = Convert::raw2sql($limit); @@ -137,10 +137,11 @@ class SearchContext extends Object { } } - $query->connective = $this->connective; $query->distinct = true; + $model->extend('augmentSQL', $query); + return $query; } diff --git a/search/filters/SearchFilter.php b/search/filters/SearchFilter.php index 75f30b831..bc9403d0f 100644 --- a/search/filters/SearchFilter.php +++ b/search/filters/SearchFilter.php @@ -94,7 +94,7 @@ abstract class SearchFilter extends Object { } if($candidateClass == 'DataObject') user_error("Couldn't find field $this->name in any of $this->model's tables.", E_USER_ERROR); - return $candidateClass . "." . $this->name; + return "`$candidateClass`.`$this->name`"; } /**