mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove unused ActiveRecord::Base.connection_id
This method appears to have been partially used in connection pool caching, but it was introduced without much reasoning or any tests. One edge case test was added later on, but it was focused on implementation details. This method is no longer used outside of tests, and as such is removed.
This commit is contained in:
parent
10539ad7a9
commit
4565de0da1
5 changed files with 9 additions and 28 deletions
|
@ -1,3 +1,8 @@
|
|||
* Removed the unused methods `ActiveRecord::Base.connection_id` and
|
||||
`ActiveRecord::Base.connection_id=`
|
||||
|
||||
*Sean Griffin*
|
||||
|
||||
* Ensure hashes can be assigned to attributes created using `composed_of`.
|
||||
Fixes #25210.
|
||||
|
||||
|
|
|
@ -98,14 +98,6 @@ module ActiveRecord
|
|||
@connection_specification_name
|
||||
end
|
||||
|
||||
def connection_id
|
||||
ActiveRecord::RuntimeRegistry.connection_id ||= Thread.current.object_id
|
||||
end
|
||||
|
||||
def connection_id=(connection_id)
|
||||
ActiveRecord::RuntimeRegistry.connection_id = connection_id
|
||||
end
|
||||
|
||||
# Returns the configuration of the associated connection as a hash:
|
||||
#
|
||||
# ActiveRecord::Base.connection_config
|
||||
|
|
|
@ -26,16 +26,12 @@ module ActiveRecord
|
|||
def self.run
|
||||
connection = ActiveRecord::Base.connection
|
||||
enabled = connection.query_cache_enabled
|
||||
connection_id = ActiveRecord::Base.connection_id
|
||||
connection.enable_query_cache!
|
||||
|
||||
[enabled, connection_id]
|
||||
enabled
|
||||
end
|
||||
|
||||
def self.complete(state)
|
||||
enabled, connection_id = state
|
||||
|
||||
ActiveRecord::Base.connection_id = connection_id
|
||||
def self.complete(enabled)
|
||||
ActiveRecord::Base.connection.clear_query_cache
|
||||
ActiveRecord::Base.connection.disable_query_cache! unless enabled
|
||||
end
|
||||
|
|
|
@ -12,9 +12,9 @@ module ActiveRecord
|
|||
class RuntimeRegistry # :nodoc:
|
||||
extend ActiveSupport::PerThreadRegistry
|
||||
|
||||
attr_accessor :connection_handler, :sql_runtime, :connection_id
|
||||
attr_accessor :connection_handler, :sql_runtime
|
||||
|
||||
[:connection_handler, :sql_runtime, :connection_id].each do |val|
|
||||
[:connection_handler, :sql_runtime].each do |val|
|
||||
class_eval %{ def self.#{val}; instance.#{val}; end }, __FILE__, __LINE__
|
||||
class_eval %{ def self.#{val}=(x); instance.#{val}=x; end }, __FILE__, __LINE__
|
||||
end
|
||||
|
|
|
@ -39,18 +39,6 @@ class QueryCacheTest < ActiveRecord::TestCase
|
|||
assert ActiveRecord::Base.connection.query_cache_enabled, 'cache on'
|
||||
end
|
||||
|
||||
def test_exceptional_middleware_assigns_original_connection_id_on_error
|
||||
connection_id = ActiveRecord::Base.connection_id
|
||||
|
||||
mw = middleware { |env|
|
||||
ActiveRecord::Base.connection_id = self.object_id
|
||||
raise "lol borked"
|
||||
}
|
||||
assert_raises(RuntimeError) { mw.call({}) }
|
||||
|
||||
assert_equal connection_id, ActiveRecord::Base.connection_id
|
||||
end
|
||||
|
||||
def test_middleware_delegates
|
||||
called = false
|
||||
mw = middleware { |env|
|
||||
|
|
Loading…
Reference in a new issue