public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to 
a boolean)(Andreas Korth) [#857 state:committed]
dhh (author)
Mon Oct 27 09:16:45 -0700 2008
commit  c94ba8150a726da4a894cd8325ee682a3286ec9f
tree    d9a7c710747e8f9e491ca74edfa17c20a1f9020e
parent  9e2bb2caff2b6fd4712ca3db258b68a588a69e9a
...
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
0
@@ -1,3 +1,8 @@
0
+*2.2.1 [RC2 or 2.2 final]*
0
+
0
+* Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth]
0
+
0
+
0
 *2.2.0 [RC1] (October 24th, 2008)*
0
 
0
 * Skip collection ids reader optimization if using :finder_sql [Jeremy Kemper]
...
2938
2939
2940
2941
 
2942
2943
2944
...
2938
2939
2940
 
2941
2942
2943
2944
0
@@ -2938,7 +2938,7 @@ module ActiveRecord #:nodoc:
0
       end
0
 
0
       def object_from_yaml(string)
0
-        return string unless string.is_a?(String)
0
+        return string unless string.is_a?(String) && string =~ /^---/
0
         YAML::load(string) rescue string
0
       end
0
 
...
1429
1430
1431
 
 
 
 
 
 
1432
1433
1434
...
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
0
@@ -1429,6 +1429,12 @@ class BasicsTest < ActiveRecord::TestCase
0
     topic = Topic.create("content" => myobj).reload
0
     assert_equal(myobj, topic.content)
0
   end
0
+  
0
+  def test_serialized_string_attribute
0
+    myobj = "Yes"
0
+    topic = Topic.create("content" => myobj).reload
0
+    assert_equal(myobj, topic.content)
0
+  end
0
 
0
   def test_nil_serialized_attribute_with_class_constraint
0
     myobj = MyObject.new('value1', 'value2')

Comments