@@ -616,9 +616,17 class Query < ActiveRecord::Base | |||
|
616 | 616 | sql = "#{db_table}.#{db_field} IS NOT NULL" |
|
617 | 617 | sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter |
|
618 | 618 | when ">=" |
|
619 | if is_custom_filter | |
|
620 | sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_i}" | |
|
621 | else | |
|
619 | 622 | sql = "#{db_table}.#{db_field} >= #{value.first.to_i}" |
|
623 | end | |
|
620 | 624 | when "<=" |
|
625 | if is_custom_filter | |
|
626 | sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_i}" | |
|
627 | else | |
|
621 | 628 | sql = "#{db_table}.#{db_field} <= #{value.first.to_i}" |
|
629 | end | |
|
622 | 630 | when "o" |
|
623 | 631 | sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id" |
|
624 | 632 | when "c" |
@@ -108,6 +108,29 class QueryTest < ActiveSupport::TestCase | |||
|
108 | 108 | find_issues_with_query(query) |
|
109 | 109 | end |
|
110 | 110 | |
|
111 | def test_operator_greater_than_on_custom_field | |
|
112 | f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true) | |
|
113 | query = Query.new(:project => Project.find(1), :name => '_') | |
|
114 | query.add_filter("cf_#{f.id}", '>=', ['40']) | |
|
115 | assert query.statement.include?("CAST(custom_values.value AS decimal(60,3)) >= 40") | |
|
116 | find_issues_with_query(query) | |
|
117 | end | |
|
118 | ||
|
119 | def test_operator_lesser_than | |
|
120 | query = Query.new(:project => Project.find(1), :name => '_') | |
|
121 | query.add_filter('done_ratio', '<=', ['30']) | |
|
122 | assert query.statement.include?("#{Issue.table_name}.done_ratio <= 30") | |
|
123 | find_issues_with_query(query) | |
|
124 | end | |
|
125 | ||
|
126 | def test_operator_lesser_than_on_custom_field | |
|
127 | f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true) | |
|
128 | query = Query.new(:project => Project.find(1), :name => '_') | |
|
129 | query.add_filter("cf_#{f.id}", '<=', ['30']) | |
|
130 | assert query.statement.include?("CAST(custom_values.value AS decimal(60,3)) <= 30") | |
|
131 | find_issues_with_query(query) | |
|
132 | end | |
|
133 | ||
|
111 | 134 | def test_operator_in_more_than |
|
112 | 135 | Issue.find(7).update_attribute(:due_date, (Date.today + 15)) |
|
113 | 136 | query = Query.new(:project => Project.find(1), :name => '_') |
General Comments 0
You need to be logged in to leave comments.
Login now