do not depend on to_yaml being called, but rather depend on YAML being dumped
This commit is contained in:
parent
0f8a6ebba3
commit
1f4dae9daa
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue