提交 ccaa3e47 编写于 作者: R Rafael Mendonça França

Merge pull request #13412 from arthurnn/quote_id_not_id

quoting: Check if id is a valid method before using it
......@@ -43,7 +43,9 @@ def quote(value, column = nil)
# SQLite does not understand dates, so this method will convert a Date
# to a String.
def type_cast(value, column)
return value.id if value.respond_to?(:quoted_id)
if value.respond_to?(:quoted_id) && value.respond_to?(:id)
return value.id
end
case value
when String, ActiveSupport::Multibyte::Chars
......
......@@ -95,6 +95,13 @@ def id
end
}.new
assert_equal 10, @conn.type_cast(quoted_id_obj, nil)
quoted_id_obj = Class.new {
def quoted_id
"'zomg'"
end
}
assert_raise(TypeError) { @conn.type_cast(quoted_id_obj, nil) }
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册