Permalink
Browse files

Fixed that serialized strings should never be type-casted (i.e. turni…

…ng "Yes" to a boolean)(Andreas Korth) [#857 state:committed]
  • Loading branch information...
1 parent 9e2bb2c commit c94ba8150a726da4a894cd8325ee682a3286ec9f @dhh dhh committed Oct 27, 2008
Showing with 12 additions and 1 deletion.
  1. +5 −0 activerecord/CHANGELOG
  2. +1 −1 activerecord/lib/active_record/base.rb
  3. +6 −0 activerecord/test/cases/base_test.rb
@@ -1,3 +1,8 @@
+*2.2.1 [RC2 or 2.2 final]*
+
+* Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth]
+
+
*2.2.0 [RC1] (October 24th, 2008)*
* Skip collection ids reader optimization if using :finder_sql [Jeremy Kemper]
@@ -2938,7 +2938,7 @@ def quoted_comma_pair_list(quoter, hash)
end
def object_from_yaml(string)
- return string unless string.is_a?(String)
+ return string unless string.is_a?(String) && string =~ /^---/
YAML::load(string) rescue string
end
@@ -1429,6 +1429,12 @@ def test_serialized_time_attribute
topic = Topic.create("content" => myobj).reload
assert_equal(myobj, topic.content)
end
+
+ def test_serialized_string_attribute
+ myobj = "Yes"
+ topic = Topic.create("content" => myobj).reload
+ assert_equal(myobj, topic.content)
+ end
def test_nil_serialized_attribute_with_class_constraint
myobj = MyObject.new('value1', 'value2')

0 comments on commit c94ba81

Please sign in to comment.