diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-06-29 09:46:45 -0400 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-06-29 09:50:52 -0400 |
commit | 4565de0da14a4b3d75e8b1a652fcb6dcd947c451 (patch) | |
tree | 4d4d2bebc90c9fe78f5f3e834bc9072b982ec650 | |
parent | 10539ad7a998d305dd94d0ff3b39991ad3918c18 (diff) | |
download | rails-4565de0da14a4b3d75e8b1a652fcb6dcd947c451.tar.gz rails-4565de0da14a4b3d75e8b1a652fcb6dcd947c451.tar.bz2 rails-4565de0da14a4b3d75e8b1a652fcb6dcd947c451.zip |
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.
-rw-r--r-- | activerecord/CHANGELOG.md | 5 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_handling.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/query_cache.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/runtime_registry.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/query_cache_test.rb | 12 |
5 files changed, 9 insertions, 28 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 0bd3c2e78c..0feda36a83 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -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. diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index 99fdef67d0..f735bc697b 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -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 diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb index 07d863d15e..fa3e306b3e 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -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 diff --git a/activerecord/lib/active_record/runtime_registry.rb b/activerecord/lib/active_record/runtime_registry.rb index 56e88bc661..9e86999c1b 100644 --- a/activerecord/lib/active_record/runtime_registry.rb +++ b/activerecord/lib/active_record/runtime_registry.rb @@ -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 diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb index d5c01315c1..03ec063671 100644 --- a/activerecord/test/cases/query_cache_test.rb +++ b/activerecord/test/cases/query_cache_test.rb @@ -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| |