Fixed: error when filtering by numeric custom field with postgresql (#9719).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8098 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+35
-4
@@ -147,6 +147,32 @@ class QueryTest < ActiveSupport::TestCase
|
||||
assert_equal 2, issues.first.id
|
||||
end
|
||||
|
||||
def test_operator_is_on_integer_custom_field
|
||||
f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_for_all => true, :is_filter => true)
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => '7')
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '12')
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
|
||||
|
||||
query = Query.new(:name => '_')
|
||||
query.add_filter("cf_#{f.id}", '=', ['12'])
|
||||
issues = find_issues_with_query(query)
|
||||
assert_equal 1, issues.size
|
||||
assert_equal 2, issues.first.id
|
||||
end
|
||||
|
||||
def test_operator_is_on_float_custom_field
|
||||
f = IssueCustomField.create!(:name => 'filter', :field_format => 'float', :is_filter => true, :is_for_all => true)
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => '7.3')
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '12.7')
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
|
||||
|
||||
query = Query.new(:name => '_')
|
||||
query.add_filter("cf_#{f.id}", '=', ['12.7'])
|
||||
issues = find_issues_with_query(query)
|
||||
assert_equal 1, issues.size
|
||||
assert_equal 2, issues.first.id
|
||||
end
|
||||
|
||||
def test_operator_greater_than
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('done_ratio', '>=', ['40'])
|
||||
@@ -161,12 +187,17 @@ class QueryTest < ActiveSupport::TestCase
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
def test_operator_greater_than_on_custom_field
|
||||
def test_operator_greater_than_on_int_custom_field
|
||||
f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true)
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => '7')
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '12')
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
|
||||
|
||||
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.0")
|
||||
find_issues_with_query(query)
|
||||
query.add_filter("cf_#{f.id}", '>=', ['8'])
|
||||
issues = find_issues_with_query(query)
|
||||
assert_equal 1, issues.size
|
||||
assert_equal 2, issues.first.id
|
||||
end
|
||||
|
||||
def test_operator_lesser_than
|
||||
|
||||
Reference in New Issue
Block a user