1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

s/specification_name/connection_specification_name

This commit is contained in:
Arthur Neves 2016-05-06 13:22:49 -05:00
parent 598e7c9e20
commit 22a127c57b
No known key found for this signature in database
GPG key ID: 04A390FB1E433E17
4 changed files with 14 additions and 14 deletions

View file

@ -51,7 +51,7 @@ module ActiveRecord
resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new configurations
# TODO: uses name on establish_connection, for backwards compatibility
spec = resolver.spec(spec, self == Base ? "primary" : name)
self.specification_name = spec.name
self.connection_specification_name = spec.name
unless respond_to?(spec.adapter_method)
raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter"
@ -91,15 +91,15 @@ module ActiveRecord
retrieve_connection
end
attr_writer :specification_name
attr_writer :connection_specification_name
# Return the specification id from this class otherwise look it up
# in the parent.
def specification_name
unless defined?(@specification_name)
@specification_name = self == Base ? "primary" : superclass.specification_name
def connection_specification_name
unless defined?(@connection_specification_name)
@connection_specification_name = self == Base ? "primary" : superclass.connection_specification_name
end
@specification_name
@connection_specification_name
end
def connection_id
@ -121,19 +121,19 @@ module ActiveRecord
end
def connection_pool
connection_handler.retrieve_connection_pool(specification_name) or raise ConnectionNotEstablished
connection_handler.retrieve_connection_pool(connection_specification_name) or raise ConnectionNotEstablished
end
def retrieve_connection
connection_handler.retrieve_connection(specification_name)
connection_handler.retrieve_connection(connection_specification_name)
end
# Returns +true+ if Active Record is connected.
def connected?
connection_handler.connected?(specification_name)
connection_handler.connected?(connection_specification_name)
end
def remove_connection(name = specification_name)
def remove_connection(name = connection_specification_name)
connection_handler.remove_connection(name)
end

View file

@ -257,7 +257,7 @@ module ActiveRecord
# Returns the Arel engine.
def arel_engine # :nodoc:
@arel_engine ||=
if Base == self || connection_handler.retrieve_connection_pool(specification_name)
if Base == self || connection_handler.retrieve_connection_pool(connection_specification_name)
self
else
superclass.arel_engine

View file

@ -117,7 +117,7 @@ module ActiveRecord
end
def create_all
old_pool = ActiveRecord::Base.connection_handler.retrieve_connection_pool(ActiveRecord::Base.specification_name)
old_pool = ActiveRecord::Base.connection_handler.retrieve_connection_pool(ActiveRecord::Base.connection_specification_name)
each_local_configuration { |configuration| create configuration }
if old_pool
ActiveRecord::Base.connection_handler.establish_connection(old_pool.spec)

View file

@ -25,10 +25,10 @@ class MultipleDbTest < ActiveRecord::TestCase
end
def test_swapping_the_connection
old_spec_name, Course.specification_name = Course.specification_name, "primary"
old_spec_name, Course.connection_specification_name = Course.connection_specification_name, "primary"
assert_equal(Entrant.connection, Course.connection)
ensure
Course.specification_name = old_spec_name
Course.connection_specification_name = old_spec_name
end
def test_find