Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
034e4d38
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,发现更多精彩内容 >>
提交
034e4d38
编写于
10月 10, 2016
作者:
R
Rafael França
提交者:
GitHub
10月 10, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26745 from kamipo/dump_index_options_to_pretty_format
Dump index options to pretty format
上级
02989ee3
5025fd3a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
10 addition
and
12 deletion
+10
-12
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
..._record/connection_adapters/abstract/schema_statements.rb
+1
-1
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+2
-2
activerecord/lib/active_record/schema_dumper.rb
activerecord/lib/active_record/schema_dumper.rb
+2
-6
activerecord/test/cases/schema_dumper_test.rb
activerecord/test/cases/schema_dumper_test.rb
+4
-2
activerecord/test/schema/schema.rb
activerecord/test/schema/schema.rb
+1
-1
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
浏览文件 @
034e4d38
...
...
@@ -1192,7 +1192,7 @@ def add_options_for_index_columns(quoted_columns, **options)
def
quoted_columns_for_index
(
column_names
,
**
options
)
return
[
column_names
]
if
column_names
.
is_a?
(
String
)
quoted_columns
=
Hash
[
column_names
.
map
{
|
name
|
[
name
,
quote_column_name
(
name
).
dup
]
}]
quoted_columns
=
Hash
[
column_names
.
map
{
|
name
|
[
name
.
to_sym
,
quote_column_name
(
name
).
dup
]
}]
add_options_for_index_columns
(
quoted_columns
,
options
).
values
end
...
...
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
034e4d38
...
...
@@ -384,11 +384,11 @@ def indexes(table_name, name = nil) #:nodoc:
mysql_index_type
=
row
[
:Index_type
].
downcase
.
to_sym
index_type
=
INDEX_TYPES
.
include?
(
mysql_index_type
)
?
mysql_index_type
:
nil
index_using
=
INDEX_USINGS
.
include?
(
mysql_index_type
)
?
mysql_index_type
:
nil
indexes
<<
IndexDefinition
.
new
(
row
[
:Table
],
row
[
:Key_name
],
row
[
:Non_unique
].
to_i
==
0
,
[],
[]
,
nil
,
nil
,
index_type
,
index_using
,
row
[
:Index_comment
].
presence
)
indexes
<<
IndexDefinition
.
new
(
row
[
:Table
],
row
[
:Key_name
],
row
[
:Non_unique
].
to_i
==
0
,
[],
{}
,
nil
,
nil
,
index_type
,
index_using
,
row
[
:Index_comment
].
presence
)
end
indexes
.
last
.
columns
<<
row
[
:Column_name
]
indexes
.
last
.
lengths
<<
row
[
:Sub_part
]
indexes
.
last
.
lengths
.
merge!
(
row
[
:Column_name
]
=>
row
[
:Sub_part
])
if
row
[
:Sub_part
]
end
end
...
...
activerecord/lib/active_record/schema_dumper.rb
浏览文件 @
034e4d38
...
...
@@ -192,12 +192,8 @@ def index_parts(index)
"name:
#{
index
.
name
.
inspect
}
"
,
]
index_parts
<<
"unique: true"
if
index
.
unique
index_lengths
=
(
index
.
lengths
||
[]).
compact
index_parts
<<
"length:
#{
Hash
[
index
.
columns
.
zip
(
index
.
lengths
)].
inspect
}
"
if
index_lengths
.
any?
index_orders
=
index
.
orders
||
{}
index_parts
<<
"order:
#{
index
.
orders
.
inspect
}
"
if
index_orders
.
any?
index_parts
<<
"length: {
#{
format_options
(
index
.
lengths
)
}
}"
if
index
.
lengths
.
present?
index_parts
<<
"order: {
#{
format_options
(
index
.
orders
)
}
}"
if
index
.
orders
.
present?
index_parts
<<
"where:
#{
index
.
where
.
inspect
}
"
if
index
.
where
index_parts
<<
"using:
#{
index
.
using
.
inspect
}
"
if
index
.
using
index_parts
<<
"type:
#{
index
.
type
.
inspect
}
"
if
index
.
type
...
...
activerecord/test/cases/schema_dumper_test.rb
浏览文件 @
034e4d38
...
...
@@ -183,8 +183,10 @@ def test_schema_dump_with_regexp_ignored_table
def
test_schema_dumps_index_columns_in_right_order
index_definition
=
standard_dump
.
split
(
/\n/
).
grep
(
/t\.index.*company_index/
).
first
.
strip
if
current_adapter?
(
:Mysql2Adapter
,
:PostgreSQLAdapter
)
assert_equal
't.index ["firm_id", "type", "rating"], name: "company_index", using: :btree'
,
index_definition
if
current_adapter?
(
:PostgreSQLAdapter
)
assert_equal
't.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree'
,
index_definition
elsif
current_adapter?
(
:Mysql2Adapter
)
assert_equal
't.index ["firm_id", "type", "rating"], name: "company_index", length: { type: 10 }, using: :btree'
,
index_definition
else
assert_equal
't.index ["firm_id", "type", "rating"], name: "company_index"'
,
index_definition
end
...
...
activerecord/test/schema/schema.rb
浏览文件 @
034e4d38
...
...
@@ -197,7 +197,7 @@
t
.
integer
:rating
,
default:
1
t
.
integer
:account_id
t
.
string
:description
,
default:
""
t
.
index
[
:firm_id
,
:type
,
:rating
],
name:
"company_index"
t
.
index
[
:firm_id
,
:type
,
:rating
],
name:
"company_index"
,
length:
{
type:
10
},
order:
{
rating: :desc
}
t
.
index
[
:firm_id
,
:type
],
name:
"company_partial_index"
,
where:
"rating > 10"
t
.
index
:name
,
name:
"company_name_index"
,
using: :btree
t
.
index
"lower(name)"
,
name:
"company_expression_index"
if
supports_expression_index?
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录