Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a31e8374
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,发现更多精彩内容 >>
提交
a31e8374
编写于
6月 10, 2016
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prevent `table_comment` query if a table doesn't have a comment
上级
f9a39e0d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
7 deletion
+17
-7
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+9
-3
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
...ecord/connection_adapters/postgresql/schema_statements.rb
+4
-0
activerecord/lib/active_record/schema_dumper.rb
activerecord/lib/active_record/schema_dumper.rb
+4
-4
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
a31e8374
...
...
@@ -542,7 +542,9 @@ def foreign_keys(table_name)
end
end
def
table_options
(
table_name
)
def
table_options
(
table_name
)
# :nodoc:
table_options
=
{}
create_table_info
=
create_table_info
(
table_name
)
# strip create_definitions and partition_options
...
...
@@ -551,10 +553,14 @@ def table_options(table_name)
# strip AUTO_INCREMENT
raw_table_options
.
sub!
(
/(ENGINE=\w+)(?: AUTO_INCREMENT=\d+)/
,
'\1'
)
table_options
[
:options
]
=
raw_table_options
# strip COMMENT
raw_table_options
.
sub!
(
/ COMMENT='.+'/
,
''
)
if
raw_table_options
.
sub!
(
/ COMMENT='.+'/
,
''
)
table_options
[
:comment
]
=
table_comment
(
table_name
)
end
raw_
table_options
table_options
end
# Maps logical Rails types to MySQL-specific data types.
...
...
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
浏览文件 @
a31e8374
...
...
@@ -238,6 +238,10 @@ def new_column(*args) # :nodoc:
PostgreSQLColumn
.
new
(
*
args
)
end
def
table_options
(
table_name
)
# :nodoc:
{
comment:
table_comment
(
table_name
)
}
end
# Returns a comment stored in database for given table
def
table_comment
(
table_name
)
# :nodoc:
name
=
Utils
.
extract_schema_qualified_name
(
table_name
.
to_s
)
...
...
activerecord/lib/active_record/schema_dumper.rb
浏览文件 @
a31e8374
...
...
@@ -132,10 +132,10 @@ def table(table, stream)
tbl
.
print
", force: :cascade"
table_options
=
@connection
.
table_options
(
table
)
tbl
.
print
", options:
#{
table_options
.
inspect
}
"
unless
table_options
.
blank
?
if
comment
=
@connection
.
table_comment
(
table
).
presence
tbl
.
print
", comment:
#{
comment
.
inspect
}
"
if
table_options
.
present
?
table_options
.
each
do
|
key
,
value
|
tbl
.
print
",
#{
key
}
:
#{
value
.
inspect
}
"
if
value
.
present?
end
end
tbl
.
puts
" do |t|"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录