diff --git a/search/filters/GreaterThanFilter.php b/search/filters/GreaterThanFilter.php index 12540e160..20c95e24d 100644 --- a/search/filters/GreaterThanFilter.php +++ b/search/filters/GreaterThanFilter.php @@ -17,7 +17,7 @@ class GreaterThanFilter extends SearchFilter { return $query->where(sprintf( "%s > '%s'", $this->getDbName(), - Convert::raw2sql($this->getValue()) + Convert::raw2sql($this->getDbFormattedValue()) )); } diff --git a/search/filters/SearchFilter.php b/search/filters/SearchFilter.php index 1077889d9..b295bd083 100644 --- a/search/filters/SearchFilter.php +++ b/search/filters/SearchFilter.php @@ -94,6 +94,20 @@ abstract class SearchFilter extends Object { return $candidateClass . "." . $this->name; } + /** + * Return the value of the field as processed by the DBField class + * + * @return string + */ + function getDbFormattedValue() { + // SRM: This code finds the table where the field named $this->name lives + // Todo: move to somewhere more appropriate, such as DataMapper, the magical class-to-be? + $candidateClass = $this->model; + $dbField = singleton($this->model)->dbObject($this->name); + $dbField->setValue($this->value); + return $dbField->RAW(); + } + /** * Traverse the relationship fields, and add the table * mappings to the query object state.