Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5167b8f7
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
5167b8f7
编写于
5月 07, 2016
作者:
A
Arthur Neves
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move establish_connection to handler
上级
bf219714
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
14 deletion
+18
-14
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
...ve_record/connection_adapters/abstract/connection_pool.rb
+9
-1
activerecord/lib/active_record/connection_adapters/connection_specification.rb
...ve_record/connection_adapters/connection_specification.rb
+4
-0
activerecord/lib/active_record/connection_handling.rb
activerecord/lib/active_record/connection_handling.rb
+5
-13
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
浏览文件 @
5167b8f7
...
@@ -837,7 +837,15 @@ def connection_pool_list
...
@@ -837,7 +837,15 @@ def connection_pool_list
end
end
alias
:connection_pools
:connection_pool_list
alias
:connection_pools
:connection_pool_list
def
establish_connection
(
spec
)
def
establish_connection
(
spec_or_config
,
name:
"primary"
)
if
spec_or_config
.
is_a?
(
ConnectionSpecification
)
spec
=
spec_or_config
else
resolver
=
ConnectionAdapters
::
ConnectionSpecification
::
Resolver
.
new
(
ActiveRecord
::
Base
.
configurations
)
spec
=
resolver
.
spec
(
spec_or_config
,
name
)
end
remove_connection
(
spec
.
name
)
owner_to_pool
[
spec
.
name
]
=
ConnectionAdapters
::
ConnectionPool
.
new
(
spec
)
owner_to_pool
[
spec
.
name
]
=
ConnectionAdapters
::
ConnectionPool
.
new
(
spec
)
end
end
...
...
activerecord/lib/active_record/connection_adapters/connection_specification.rb
浏览文件 @
5167b8f7
...
@@ -180,6 +180,10 @@ def spec(config, name = nil)
...
@@ -180,6 +180,10 @@ def spec(config, name = nil)
adapter_method
=
"
#{
spec
[
:adapter
]
}
_connection"
adapter_method
=
"
#{
spec
[
:adapter
]
}
_connection"
unless
ActiveRecord
::
Base
.
respond_to?
(
adapter_method
)
raise
AdapterNotFound
,
"database configuration specifies nonexistent
#{
spec
.
config
[
:adapter
]
}
adapter"
end
name
||=
name
||=
if
config
.
is_a?
(
Symbol
)
if
config
.
is_a?
(
Symbol
)
config
.
to_s
config
.
to_s
...
...
activerecord/lib/active_record/connection_handling.rb
浏览文件 @
5167b8f7
...
@@ -44,21 +44,13 @@ module ConnectionHandling
...
@@ -44,21 +44,13 @@ module ConnectionHandling
#
#
# The exceptions AdapterNotSpecified, AdapterNotFound and +ArgumentError+
# The exceptions AdapterNotSpecified, AdapterNotFound and +ArgumentError+
# may be returned on an error.
# may be returned on an error.
def
establish_connection
(
spec
=
nil
)
def
establish_connection
(
config
=
nil
)
raise
"Anonymous class is not allowed."
unless
name
raise
"Anonymous class is not allowed."
unless
name
spec
||=
DEFAULT_ENV
.
call
.
to_sym
config
||=
DEFAULT_ENV
.
call
.
to_sym
resolver
=
ConnectionAdapters
::
ConnectionSpecification
::
Resolver
.
new
configurations
spec_name
=
self
==
Base
?
"primary"
:
name
# TODO: uses name on establish_connection, for backwards compatibility
self
.
connection_specification_name
=
spec_name
spec
=
resolver
.
spec
(
spec
,
self
==
Base
?
"primary"
:
name
)
connection_handler
.
establish_connection
(
config
,
name:
spec_name
)
unless
respond_to?
(
spec
.
adapter_method
)
raise
AdapterNotFound
,
"database configuration specifies nonexistent
#{
spec
.
config
[
:adapter
]
}
adapter"
end
remove_connection
(
spec
.
name
)
self
.
connection_specification_name
=
spec
.
name
connection_handler
.
establish_connection
spec
end
end
class
MergeAndResolveDefaultUrlConfig
# :nodoc:
class
MergeAndResolveDefaultUrlConfig
# :nodoc:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录