aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/type/decimal_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fixing numeric attrs when set to same negative valueDaniel Fox2014-12-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug occurs when an attribute of an ActiveRecord model is an ActiveRecord::Type::Integer type or a ActiveRecord::Type::Decimal type (or any other type that includes the ActiveRecord::Type::Numeric module. When the value of the attribute is negative and is set to the same negative value, it is marked as changed. Take the following example of a Person model with the integer attribute age: class Person < ActiveRecord::Base # age :integer(4) end The following will produce the error: person = Person.new(age: -1) person.age = -1 person.changes => { "age" => [-1, -1] } person.age_changed? => true The problematic line is here: module ActiveRecord module Type module Numeric ... def non_numeric_string?(value) # 'wibble'.to_i will give zero, we want to make sure # that we aren't marking int zero to string zero as # changed. value.to_s !~ /\A\d+\.?\d*\z/ end end end end The regex match doesn't accept numbers with a leading '-'.
* Correctly handle Float -> BigDecimal with unspecified precisionSean Griffin2014-12-221-0/+5
| | | | Fixes #18122
* Fix type casting to Decimal from Float with ...joker10072014-08-011-0/+5
| | | | | When I defines large precision column at RDBMS, I assigns float value, raise ArgumentError (precision too large).
* Fix decimal_test module and add new test for object responding to to_dMariano Valles2014-07-161-6/+15
|
* Fix case statement to use ::Numeric and ::StringMariano Valles2014-07-161-0/+24