Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
560bf1c9
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,发现更多精彩内容 >>
提交
560bf1c9
编写于
1月 11, 2016
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract `MySQL::TypeMetadata` class to `connection_adapters/mysql/type_metadata.rb`
上级
83026cb1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
29 deletion
+35
-29
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+2
-28
activerecord/lib/active_record/connection_adapters/mysql/type_metadata.rb
.../active_record/connection_adapters/mysql/type_metadata.rb
+32
-0
activerecord/test/cases/column_definition_test.rb
activerecord/test/cases/column_definition_test.rb
+1
-1
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
560bf1c9
...
...
@@ -3,6 +3,7 @@
require
'active_record/connection_adapters/mysql/schema_creation'
require
'active_record/connection_adapters/mysql/schema_definitions'
require
'active_record/connection_adapters/mysql/schema_dumper'
require
'active_record/connection_adapters/mysql/type_metadata'
require
'active_support/core_ext/string/strip'
...
...
@@ -20,33 +21,6 @@ def schema_creation
MySQL
::
SchemaCreation
.
new
(
self
)
end
class
MysqlTypeMetadata
<
DelegateClass
(
SqlTypeMetadata
)
# :nodoc:
attr_reader
:extra
,
:strict
def
initialize
(
type_metadata
,
extra:
""
,
strict:
false
)
super
(
type_metadata
)
@type_metadata
=
type_metadata
@extra
=
extra
@strict
=
strict
end
def
==
(
other
)
other
.
is_a?
(
MysqlTypeMetadata
)
&&
attributes_for_hash
==
other
.
attributes_for_hash
end
alias
eql?
==
def
hash
attributes_for_hash
.
hash
end
protected
def
attributes_for_hash
[
self
.
class
,
@type_metadata
,
extra
,
strict
]
end
end
##
# :singleton-method:
# By default, the Mysql2Adapter will consider all columns of type <tt>tinyint(1)</tt>
...
...
@@ -804,7 +778,7 @@ def extract_precision(sql_type)
end
def
fetch_type_metadata
(
sql_type
,
extra
=
""
)
My
sql
TypeMetadata
.
new
(
super
(
sql_type
),
extra:
extra
,
strict:
strict_mode?
)
My
SQL
::
TypeMetadata
.
new
(
super
(
sql_type
),
extra:
extra
,
strict:
strict_mode?
)
end
def
add_index_length
(
option_strings
,
column_names
,
options
=
{})
...
...
activerecord/lib/active_record/connection_adapters/mysql/type_metadata.rb
0 → 100644
浏览文件 @
560bf1c9
module
ActiveRecord
module
ConnectionAdapters
module
MySQL
class
TypeMetadata
<
DelegateClass
(
SqlTypeMetadata
)
# :nodoc:
attr_reader
:extra
,
:strict
def
initialize
(
type_metadata
,
extra:
""
,
strict:
false
)
super
(
type_metadata
)
@type_metadata
=
type_metadata
@extra
=
extra
@strict
=
strict
end
def
==
(
other
)
other
.
is_a?
(
MySQL
::
TypeMetadata
)
&&
attributes_for_hash
==
other
.
attributes_for_hash
end
alias
eql?
==
def
hash
attributes_for_hash
.
hash
end
protected
def
attributes_for_hash
[
self
.
class
,
@type_metadata
,
extra
,
strict
]
end
end
end
end
end
activerecord/test/cases/column_definition_test.rb
浏览文件 @
560bf1c9
...
...
@@ -64,7 +64,7 @@ def test_should_not_set_default_for_blob_and_text_data_types
MySQL
::
Column
.
new
(
"title"
,
"a"
,
SqlTypeMetadata
.
new
(
sql_type:
"blob"
))
end
text_type
=
AbstractMysqlAdapter
::
Mysql
TypeMetadata
.
new
(
text_type
=
MySQL
::
TypeMetadata
.
new
(
SqlTypeMetadata
.
new
(
type: :text
))
assert_raise
ArgumentError
do
MySQL
::
Column
.
new
(
"title"
,
"Hello"
,
text_type
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录