aaronjg
aaronjg

Reputation: 757

Ruby 1.9 migration with YAML Serialized Text Fields

I am upgrading from ruby 1.8.7 to ruby 1.9.3. I noticed that there is a difference in how YAML serialized fields are being read. Many of my serialized strings are being coerced to integers in the new YAML format. For example:

1.8.7 :010 > "2011_01".to_yaml
 => "--- 2011_01\n" 
1.8.7 :011 > YAML.load("--- 2011_01\n")

1.9.3p125 :001 > YAML.load("--- 2011_01\n")
 => 201101 

What is causing this? Is there a way to either revert to the old behavior in the new ruby, or migrate my fields to the new format?

Upvotes: 1

Views: 391

Answers (1)

aromero
aromero

Reputation: 25761

Try using syck as the parser:

ruby-1.9.3-rc1 :001 > YAML::ENGINE.yamler = "syck"
 => "syck" 
ruby-1.9.3-rc1 :002 > YAML.load("--- 2011_01\n")
 => "2011_01"

Upvotes: 2

Related Questions