From b86c2a6767b939c420687db7df078625c702dc7a Mon Sep 17 00:00:00 2001
From: Ryuta Kamizono <kamipo@gmail.com>
Date: Wed, 31 Oct 2018 12:02:22 +0900
Subject: Fix "warning: shadowing outer local variable - role"

Caused at #34196.
---
 .../lib/active_record/connection_handling.rb       | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb
index e3b59b8a22..777cb8a402 100644
--- a/activerecord/lib/active_record/connection_handling.rb
+++ b/activerecord/lib/active_record/connection_handling.rb
@@ -109,15 +109,19 @@ module ActiveRecord
       if database && role
         raise ArgumentError, "connected_to can only accept a database or role argument, but not both arguments."
       elsif database
-        database = { database => database } if database.is_a?(Symbol)
-        database.each do |role, database_key|
-          config_hash = resolve_config_for_connection(database_key)
-          handler = lookup_connection_handler(role.to_sym)
-
-          with_handler(role.to_sym) do
-            handler.establish_connection(config_hash)
-            return yield
-          end
+        if database.is_a?(Hash)
+          role, database = database.first
+          role = role.to_sym
+        else
+          role = database.to_sym
+        end
+
+        config_hash = resolve_config_for_connection(database)
+        handler = lookup_connection_handler(role)
+
+        with_handler(role) do
+          handler.establish_connection(config_hash)
+          yield
         end
       elsif role
         with_handler(role.to_sym, &blk)
-- 
cgit v1.2.3