diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-13 11:41:34 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-13 11:41:42 -0700 |
commit | 1f4dae9daa8d5be44a676f59681c013e8f501e8f (patch) | |
tree | ecadad5498d54f86121fef70414cc638e2bd895f /activerecord | |
parent | 0f8a6ebba39e278b9a4426cdc4f5139484585afd (diff) | |
download | rails-1f4dae9daa8d5be44a676f59681c013e8f501e8f.tar.gz rails-1f4dae9daa8d5be44a676f59681c013e8f501e8f.tar.bz2 rails-1f4dae9daa8d5be44a676f59681c013e8f501e8f.zip |
do not depend on to_yaml being called, but rather depend on YAML being dumped
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/quoting.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/quoting_test.rb | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 7489e88eef..325665dd87 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -35,7 +35,7 @@ module ActiveRecord when Date, Time then "'#{quoted_date(value)}'" when Symbol then "'#{quote_string(value.to_s)}'" else - "'#{quote_string(value.to_yaml)}'" + "'#{quote_string(YAML.dump(value))}'" end end diff --git a/activerecord/test/cases/quoting_test.rb b/activerecord/test/cases/quoting_test.rb index b87fb51d97..80ee74e41e 100644 --- a/activerecord/test/cases/quoting_test.rb +++ b/activerecord/test/cases/quoting_test.rb @@ -154,15 +154,16 @@ module ActiveRecord end def test_crazy_object - crazy = Class.new { def to_yaml; 'lol' end }.new - assert_equal "'lol'", @quoter.quote(crazy, nil) - assert_equal "'lol'", @quoter.quote(crazy, Object.new) + crazy = Class.new.new + expected = "'#{YAML.dump(crazy)}'" + assert_equal expected, @quoter.quote(crazy, nil) + assert_equal expected, @quoter.quote(crazy, Object.new) end def test_crazy_object_calls_quote_string - crazy = Class.new { def to_yaml; 'lo\l' end }.new - assert_equal "'lo\\\\l'", @quoter.quote(crazy, nil) - assert_equal "'lo\\\\l'", @quoter.quote(crazy, Object.new) + crazy = Class.new { def initialize; @lol = 'lo\l' end }.new + assert_match "lo\\\\l", @quoter.quote(crazy, nil) + assert_match "lo\\\\l", @quoter.quote(crazy, Object.new) end def test_quote_string_no_column |