Skip to content
This repository
Browse code

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...
commit c94ba8150a726da4a894cd8325ee682a3286ec9f 1 parent 9e2bb2c
David Heinemeier Hansson authored October 27, 2008
5  activerecord/CHANGELOG
... ...
@@ -1,3 +1,8 @@
  1
+*2.2.1 [RC2 or 2.2 final]*
  2
+
  3
+* Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth]
  4
+
  5
+
1 6
 *2.2.0 [RC1] (October 24th, 2008)*
2 7
 
3 8
 * Skip collection ids reader optimization if using :finder_sql [Jeremy Kemper]
2  activerecord/lib/active_record/base.rb
@@ -2938,7 +2938,7 @@ def quoted_comma_pair_list(quoter, hash)
2938 2938
       end
2939 2939
 
2940 2940
       def object_from_yaml(string)
2941  
-        return string unless string.is_a?(String)
  2941
+        return string unless string.is_a?(String) && string =~ /^---/
2942 2942
         YAML::load(string) rescue string
2943 2943
       end
2944 2944
 
6  activerecord/test/cases/base_test.rb
@@ -1429,6 +1429,12 @@ def test_serialized_time_attribute
1429 1429
     topic = Topic.create("content" => myobj).reload
1430 1430
     assert_equal(myobj, topic.content)
1431 1431
   end
  1432
+  
  1433
+  def test_serialized_string_attribute
  1434
+    myobj = "Yes"
  1435
+    topic = Topic.create("content" => myobj).reload
  1436
+    assert_equal(myobj, topic.content)
  1437
+  end
1432 1438
 
1433 1439
   def test_nil_serialized_attribute_with_class_constraint
1434 1440
     myobj = MyObject.new('value1', 'value2')

0 notes on commit c94ba81

Please sign in to comment.
Something went wrong with that request. Please try again.