Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
bb0c02e9
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,发现更多精彩内容 >>
未验证
提交
bb0c02e9
编写于
10月 17, 2018
作者:
R
Ryuta Kamizono
提交者:
GitHub
10月 17, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #34232 from kamipo/check_version
Consistently extract checking version for all adapters
上级
d234dd67
5b536736
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
29 addition
and
27 deletion
+29
-27
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
...lib/active_record/connection_adapters/abstract_adapter.rb
+5
-0
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+3
-8
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+15
-14
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
.../lib/active_record/connection_adapters/sqlite3_adapter.rb
+6
-5
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
浏览文件 @
bb0c02e9
...
...
@@ -125,6 +125,8 @@ def initialize(connection, logger = nil, config = {}) # :nodoc:
@advisory_locks_enabled
=
self
.
class
.
type_cast_config_to_boolean
(
config
.
fetch
(
:advisory_locks
,
true
)
)
check_version
end
def
replica?
...
...
@@ -502,6 +504,9 @@ def default_index_type?(index) # :nodoc:
end
private
def
check_version
end
def
type_map
@type_map
||=
Type
::
TypeMap
.
new
.
tap
do
|
mapping
|
initialize_type_map
(
mapping
)
...
...
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
bb0c02e9
...
...
@@ -26,7 +26,6 @@ class AbstractMysqlAdapter < AbstractAdapter
# ActiveRecord::ConnectionAdapters::Mysql2Adapter.emulate_booleans = false
class_attribute
:emulate_booleans
,
default:
true
SUPPORTED_VERSION
=
"5.5.8"
NATIVE_DATABASE_TYPES
=
{
primary_key:
"bigint auto_increment PRIMARY KEY"
,
string:
{
name:
"varchar"
,
limit:
255
},
...
...
@@ -55,7 +54,6 @@ def initialize(connection, logger, connection_options, config)
super
(
connection
,
logger
,
config
)
@statements
=
StatementPool
.
new
(
self
.
class
.
type_cast_config_to_integer
(
config
[
:statement_limit
]))
check_version
end
def
version
#:nodoc:
...
...
@@ -532,16 +530,13 @@ def insert_fixtures_set(fixture_set, tables_to_delete = [])
end
end
protected
private
def
check_version
if
version
<
SUPPORTED_VERSION
raise
"Your version of MySQL (
#{
version_string
}
) is too old. Active Record supports "
\
"MySQL >=
#{
SUPPORTED_VERSION
}
."
if
version
<
"5.5.8"
raise
"Your version of MySQL (
#{
version_string
}
) is too old. Active Record supports MySQL >= 5.5.8."
end
end
private
def
combine_multi_statements
(
total_sql
)
total_sql
.
each_with_object
([])
do
|
sql
,
total_sql_chunks
|
previous_packet
=
total_sql_chunks
.
last
...
...
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
bb0c02e9
...
...
@@ -43,9 +43,14 @@ def postgresql_connection(config)
valid_conn_param_keys
=
PG
::
Connection
.
conndefaults_hash
.
keys
+
[
:requiressl
]
conn_params
.
slice!
(
*
valid_conn_param_keys
)
# The postgres drivers don't allow the creation of an unconnected PG::Connection object,
# so just pass a nil connection object for the time being.
ConnectionAdapters
::
PostgreSQLAdapter
.
new
(
nil
,
logger
,
conn_params
,
config
)
conn
=
PG
.
connect
(
conn_params
)
ConnectionAdapters
::
PostgreSQLAdapter
.
new
(
conn
,
logger
,
conn_params
,
config
)
rescue
::
PG
::
Error
=>
error
if
error
.
message
.
include?
(
"does not exist"
)
raise
ActiveRecord
::
NoDatabaseError
else
raise
end
end
end
...
...
@@ -220,15 +225,11 @@ def initialize(connection, logger, connection_parameters, config)
@local_tz
=
nil
@max_identifier_length
=
nil
con
nect
con
figure_connection
add_pg_encoders
@statements
=
StatementPool
.
new
@connection
,
self
.
class
.
type_cast_config_to_integer
(
config
[
:statement_limit
])
if
postgresql_version
<
90100
raise
"Your version of PostgreSQL (
#{
postgresql_version
}
) is too old. Active Record supports PostgreSQL >= 9.1."
end
add_pg_decoders
@type_map
=
Type
::
HashLookupTypeMap
.
new
...
...
@@ -410,6 +411,12 @@ def default_index_type?(index) # :nodoc:
end
private
def
check_version
if
postgresql_version
<
90100
raise
"Your version of PostgreSQL (
#{
postgresql_version
}
) is too old. Active Record supports PostgreSQL >= 9.1."
end
end
# See https://www.postgresql.org/docs/current/static/errcodes-appendix.html
VALUE_LIMIT_VIOLATION
=
"22001"
NUMERIC_VALUE_OUT_OF_RANGE
=
"22003"
...
...
@@ -699,12 +706,6 @@ def prepare_statement(sql)
def
connect
@connection
=
PG
.
connect
(
@connection_parameters
)
configure_connection
rescue
::
PG
::
Error
=>
error
if
error
.
message
.
include?
(
"does not exist"
)
raise
ActiveRecord
::
NoDatabaseError
else
raise
end
end
# Configures the encoding, verbosity, schema search path, and time zone of the connection.
...
...
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
浏览文件 @
bb0c02e9
...
...
@@ -105,11 +105,6 @@ def initialize(connection, logger, connection_options, config)
@active
=
true
@statements
=
StatementPool
.
new
(
self
.
class
.
type_cast_config_to_integer
(
config
[
:statement_limit
]))
if
sqlite_version
<
"3.8.0"
raise
"Your version of SQLite (
#{
sqlite_version
}
) is too old. Active Record supports SQLite >= 3.8."
end
configure_connection
end
...
...
@@ -401,6 +396,12 @@ def insert_fixtures_set(fixture_set, tables_to_delete = [])
end
private
def
check_version
if
sqlite_version
<
"3.8.0"
raise
"Your version of SQLite (
#{
sqlite_version
}
) is too old. Active Record supports SQLite >= 3.8."
end
end
def
initialize_type_map
(
m
=
type_map
)
super
register_class_with_limit
m
,
%r(int)i
,
SQLite3Integer
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录