Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
059820c0
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,发现更多精彩内容 >>
提交
059820c0
编写于
1月 06, 2016
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21688 from kamipo/add_text_and_blob_shorthand_methods
Add short-hand methods for text and blob types in MySQL
上级
ced9612b
4d4239f9
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
53 addition
and
10 deletion
+53
-10
activerecord/CHANGELOG.md
activerecord/CHANGELOG.md
+19
-0
activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb
...ve_record/connection_adapters/mysql/schema_definitions.rb
+24
-0
activerecord/test/schema/mysql2_specific_schema.rb
activerecord/test/schema/mysql2_specific_schema.rb
+10
-10
未找到文件。
activerecord/CHANGELOG.md
浏览文件 @
059820c0
*
Add short-hand methods for text and blob types in MySQL.
In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length.
But in MySQL, these have limited length for each types (ref #21591, #21619).
This change adds short-hand methods for each text and blob types.
Example:
create_table :foos do |t|
t.tinyblob :tiny_blob
t.mediumblob :medium_blob
t.longblob :long_blob
t.tinytext :tiny_text
t.mediumtext :medium_text
t.longtext :long_text
end
*Ryuta Kamizono*
*
Take into account UTC offset when assigning string representation of
timestamp with offset specified to attribute of time type.
...
...
activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb
浏览文件 @
059820c0
...
...
@@ -11,6 +11,30 @@ def blob(*args, **options)
args
.
each
{
|
name
|
column
(
name
,
:blob
,
options
)
}
end
def
tinyblob
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:tinyblob
,
options
)
}
end
def
mediumblob
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:mediumblob
,
options
)
}
end
def
longblob
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:longblob
,
options
)
}
end
def
tinytext
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:tinytext
,
options
)
}
end
def
mediumtext
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:mediumtext
,
options
)
}
end
def
longtext
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:longtext
,
options
)
}
end
def
json
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:json
,
options
)
}
end
...
...
activerecord/test/schema/mysql2_specific_schema.rb
浏览文件 @
059820c0
...
...
@@ -2,18 +2,18 @@
create_table
:binary_fields
,
force:
true
do
|
t
|
t
.
binary
:var_binary
,
limit:
255
t
.
binary
:var_binary_large
,
limit:
4095
t
.
blob
:tiny_blob
,
limit:
255
t
.
binary
:normal_blob
,
limit:
65535
t
.
binary
:medium_blob
,
limit:
16777215
t
.
binary
:long_blob
,
limit:
2147483647
t
.
text
:tiny_text
,
limit:
255
t
.
text
:normal_text
,
limit:
65535
t
.
text
:medium_text
,
limit:
16777215
t
.
text
:long_text
,
limit:
2147483647
t
.
tinyblob
:tiny_blob
t
.
blob
:normal_blob
t
.
mediumblob
:medium_blob
t
.
longblob
:long_blob
t
.
tinytext
:tiny_text
t
.
text
:normal_text
t
.
mediumtext
:medium_text
t
.
longtext
:long_text
t
.
index
:var_binary
end
add_index
:binary_fields
,
:var_binary
create_table
:key_tests
,
force:
true
,
:options
=>
'ENGINE=MyISAM'
do
|
t
|
t
.
string
:awesome
t
.
string
:pizza
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录