提交 d1552780 编写于 作者: R Ryuta Kamizono

Deprecate using `#quoted_id` in quoting

Originally `quoted_id` was used in legacy quoting mechanism. Now we use
type casting mechanism for that. Let's deprecate `quoted_id`.
上级 a5586126
* Deprecate using `#quoted_id` in quoting.
*Ryuta Kamizono*
* Fix `wait_timeout` to configurable for mysql2 adapter.
Fixes #26556.
......
......@@ -10,6 +10,8 @@ def quote(value)
value = id_value_for_database(value) if value.is_a?(Base)
if value.respond_to?(:quoted_id)
ActiveSupport::Deprecation.warn \
"Using #quoted_id is deprecated and will be removed in Rails 5.2."
return value.quoted_id
end
......
module ActiveRecord
module Sanitization
extend ActiveSupport::Concern
......@@ -207,9 +206,9 @@ def raise_if_bind_arity_mismatch(statement, expected, provided)
end
end
# TODO: Deprecate this
def quoted_id # :nodoc:
self.class.connection.quote(@attributes[self.class.primary_key].value_for_database)
end
deprecate :quoted_id
end
end
......@@ -82,7 +82,7 @@ def test_quoted_datetime_local
end
def test_quote_with_quoted_id
assert_equal 1, @quoter.quote(Struct.new(:quoted_id).new(1))
assert_deprecated { assert_equal 1, @quoter.quote(Struct.new(:quoted_id).new(1)) }
end
def test_quote_nil
......
......@@ -152,11 +152,15 @@ def test_bind_chars
end
def test_bind_record
o = Struct.new(:quoted_id).new(1)
assert_equal "1", bind("?", o)
o = Class.new {
def quoted_id
1
end
}.new
assert_deprecated { assert_equal "1", bind("?", o) }
os = [o] * 3
assert_equal "1,1,1", bind("?", os)
assert_deprecated { assert_equal "1,1,1", bind("?", os) }
end
def test_named_bind_with_postgresql_type_casts
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册