SQLServer: The size (60) given to the type 'decimal' exceeds the maximum allowed (#12713).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11098 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
9c561f9124
commit
0135dc504a
|
@ -188,7 +188,7 @@ class CustomField < ActiveRecord::Base
|
|||
# Make the database cast values into numeric
|
||||
# Postgresql will raise an error if a value can not be casted!
|
||||
# CustomValue validations should ensure that it doesn't occur
|
||||
"(SELECT CAST(cv_sort.value AS decimal(60,3)) FROM #{CustomValue.table_name} cv_sort" +
|
||||
"(SELECT CAST(cv_sort.value AS decimal(30,3)) FROM #{CustomValue.table_name} cv_sort" +
|
||||
" WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" +
|
||||
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
|
||||
" AND cv_sort.custom_field_id=#{id} AND cv_sort.value <> '' AND cv_sort.value IS NOT NULL LIMIT 1)"
|
||||
|
@ -229,7 +229,7 @@ class CustomField < ActiveRecord::Base
|
|||
" AND #{join_alias}_2.customized_id = #{join_alias}.customized_id" +
|
||||
" AND #{join_alias}_2.custom_field_id = #{join_alias}.custom_field_id)" +
|
||||
" LEFT OUTER JOIN #{value_class.table_name} #{value_join_alias}" +
|
||||
" ON CAST(#{join_alias}.value as decimal(60,0)) = #{value_join_alias}.id"
|
||||
" ON CAST(#{join_alias}.value as decimal(30,0)) = #{value_join_alias}.id"
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -532,13 +532,13 @@ class Query < ActiveRecord::Base
|
|||
sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))
|
||||
when :integer
|
||||
if is_custom_filter
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) = #{value.first.to_i})"
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(30,3)) = #{value.first.to_i})"
|
||||
else
|
||||
sql = "#{db_table}.#{db_field} = #{value.first.to_i}"
|
||||
end
|
||||
when :float
|
||||
if is_custom_filter
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})"
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})"
|
||||
else
|
||||
sql = "#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}"
|
||||
end
|
||||
|
@ -567,7 +567,7 @@ class Query < ActiveRecord::Base
|
|||
sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)
|
||||
else
|
||||
if is_custom_filter
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f})"
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(30,3)) >= #{value.first.to_f})"
|
||||
else
|
||||
sql = "#{db_table}.#{db_field} >= #{value.first.to_f}"
|
||||
end
|
||||
|
@ -577,7 +577,7 @@ class Query < ActiveRecord::Base
|
|||
sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))
|
||||
else
|
||||
if is_custom_filter
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f})"
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(30,3)) <= #{value.first.to_f})"
|
||||
else
|
||||
sql = "#{db_table}.#{db_field} <= #{value.first.to_f}"
|
||||
end
|
||||
|
@ -587,7 +587,7 @@ class Query < ActiveRecord::Base
|
|||
sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))
|
||||
else
|
||||
if is_custom_filter
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})"
|
||||
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})"
|
||||
else
|
||||
sql = "#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}"
|
||||
end
|
||||
|
|
|
@ -328,7 +328,7 @@ class QueryTest < ActiveSupport::TestCase
|
|||
f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true)
|
||||
query = IssueQuery.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.0")
|
||||
assert query.statement.include?("CAST(custom_values.value AS decimal(30,3)) <= 30.0")
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
|
@ -343,7 +343,7 @@ class QueryTest < ActiveSupport::TestCase
|
|||
f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true)
|
||||
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter("cf_#{f.id}", '><', ['30', '40'])
|
||||
assert_include "CAST(custom_values.value AS decimal(60,3)) BETWEEN 30.0 AND 40.0", query.statement
|
||||
assert_include "CAST(custom_values.value AS decimal(30,3)) BETWEEN 30.0 AND 40.0", query.statement
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue