sql = "#{db_table}.#{db_field} IS NOT NULL"
sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter
when ">="
- sql = "#{db_table}.#{db_field} >= #{value.first.to_i}"
+ if is_custom_filter
+ sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_i}"
+ else
+ sql = "#{db_table}.#{db_field} >= #{value.first.to_i}"
+ end
when "<="
- sql = "#{db_table}.#{db_field} <= #{value.first.to_i}"
+ if is_custom_filter
+ sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_i}"
+ else
+ sql = "#{db_table}.#{db_field} <= #{value.first.to_i}"
+ end
when "o"
sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id"
when "c"
assert query.statement.include?("#{Issue.table_name}.done_ratio >= 40")
find_issues_with_query(query)
end
+
+ def test_operator_greater_than_on_custom_field
+ f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true)
+ query = Query.new(:project => Project.find(1), :name => '_')
+ query.add_filter("cf_#{f.id}", '>=', ['40'])
+ assert query.statement.include?("CAST(custom_values.value AS decimal(60,3)) >= 40")
+ find_issues_with_query(query)
+ end
+
+ def test_operator_lesser_than
+ query = Query.new(:project => Project.find(1), :name => '_')
+ query.add_filter('done_ratio', '<=', ['30'])
+ assert query.statement.include?("#{Issue.table_name}.done_ratio <= 30")
+ find_issues_with_query(query)
+ end
+
+ def test_operator_lesser_than_on_custom_field
+ f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true)
+ query = Query.new(:project => Project.find(1), :name => '_')
+ query.add_filter("cf_#{f.id}", '<=', ['30'])
+ assert query.statement.include?("CAST(custom_values.value AS decimal(60,3)) <= 30")
+ find_issues_with_query(query)
+ end
def test_operator_in_more_than
Issue.find(7).update_attribute(:due_date, (Date.today + 15))