Index: trunk/core/units/general/helpers/search_helper.php =================================================================== diff -u -N -r6831 -r6832 --- trunk/core/units/general/helpers/search_helper.php (.../search_helper.php) (revision 6831) +++ trunk/core/units/general/helpers/search_helper.php (.../search_helper.php) (revision 6832) @@ -348,6 +348,17 @@ return $custom_filter; } + /** + * Return numeric range filter value + checking that it's number + * + * @param Array $value array containing range filter value + * @return unknown + */ + function getRangeValue($value) + { + return $value && is_numeric($value) ? $this->Conn->qstr($value) : false; + } + function getCustomFilterSearchClause(&$object, $field_name, $filter_type, $field_options) { if ($filter_type == 'date_range') { @@ -361,8 +372,8 @@ switch ($filter_type) { case 'range': - $from = $field_options['submit_value']['from'] ? $this->Conn->qstr($field_options['submit_value']['from']) : false; - $to = $field_options['submit_value']['to'] ? $this->Conn->qstr($field_options['submit_value']['to']) : false; + $from = $this->getRangeValue($field_options['submit_value']['from']); + $to = $this->getRangeValue($field_options['submit_value']['to']); if ($from !== false && $to !== false) { // add range filter @@ -378,6 +389,25 @@ } break; + case 'float_range': + // MySQL can't compare values in "float" type columns using "=" operator + $from = $this->getRangeValue($field_options['submit_value']['from']); + $to = $this->getRangeValue($field_options['submit_value']['to']); + + if ($from !== false && $to !== false) { + // add range filter + $filter_value = $table_name.'`'.$field_name.'` >= '.$from.' AND '.$table_name.'`'.$field_name.'` <= '.$to; + } + elseif ($from !== false) { + // add equals filter on $from + $filter_value = 'ABS('.$table_name.'`'.$field_name.'` - '.$from.') <= 0.0001'; + } + elseif ($to !== false) { + // add equals filter on $to + $filter_value = 'ABS('.$table_name.'`'.$field_name.'` - '.$to.') <= 0.0001'; + } + break; + case 'date_range': $from = $this->processRangeField($object, $field_name, $field_options['submit_value'], 'from'); $to = $this->processRangeField($object, $field_name, $field_options['submit_value'], 'to');