提交 9caa0cf5 编写于 作者: R Ryuta Kamizono

Deprecate `supports_statement_cache?`

`supports_statement_cache?` was introduced in 3.1.0.beta1 (104d0b26) for
bind parameter substitution, but it is no longer used in 3.1.0.rc1
(73ff6797). Originally it should respect `prepared_statements` rather
than `supports_statement_cache?` (fd398475).
One more thing, named `supports_statement_cache?` is pretty misreading.
We have `StatementCache` and `StatementPool`. However,
`supports_statement_cache?` doesn't mean `StatementCache`, but
`StatementPool` unlike its name.

https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/statement_cache.rb
https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/connection_adapters/statement_pool.rb
上级 7cb71c5c
* Deprecate `supports_statement_cache?`.
*Ryuta Kamizono*
* Quote database name in `db:create` grant statement (when database user does not have access to create the database).
*Rune Philosof*
......
......@@ -137,9 +137,10 @@ def delete(arel, name = nil, binds = [])
# Returns +true+ when the connection adapter supports prepared statement
# caching, otherwise returns +false+
def supports_statement_cache?
false
def supports_statement_cache? # :nodoc:
true
end
deprecate :supports_statement_cache?
# Runs the given block in a database transaction, and returns the result
# of the block.
......
......@@ -76,12 +76,6 @@ def supports_bulk_alter? #:nodoc:
true
end
# Returns true, since this connection adapter supports prepared statement
# caching.
def supports_statement_cache?
true
end
def supports_index_sort_order?
!mariadb? && version >= "8.0.1"
end
......
......@@ -121,12 +121,6 @@ class PostgreSQLAdapter < AbstractAdapter
include PostgreSQL::DatabaseStatements
include PostgreSQL::ColumnDumper
# Returns true, since this connection adapter supports prepared statement
# caching.
def supports_statement_cache?
true
end
def supports_index_sort_order?
true
end
......
......@@ -105,12 +105,6 @@ def supports_partial_index?
sqlite_version >= "3.8.0"
end
# Returns true, since this connection adapter supports prepared statement
# caching.
def supports_statement_cache?
true
end
def requires_reloading?
true
end
......
......@@ -3,8 +3,7 @@
require "models/author"
require "models/post"
if ActiveRecord::Base.connection.supports_statement_cache? &&
ActiveRecord::Base.connection.prepared_statements
if ActiveRecord::Base.connection.prepared_statements
module ActiveRecord
class BindParameterTest < ActiveRecord::TestCase
fixtures :topics, :authors, :author_addresses, :posts
......@@ -66,6 +65,10 @@ def test_logs_legacy_binds_after_type_cast
assert_logs_binds(binds)
end
def test_deprecate_supports_statement_cache
assert_deprecated { ActiveRecord::Base.connection.supports_statement_cache? }
end
private
def assert_logs_binds(binds)
payload = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册