Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
62c01d3c
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
62c01d3c
编写于
3月 17, 2016
作者:
G
Greg Molnar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add column type option to create_join_table to support uuid
上级
f5a59883
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
2 deletion
+10
-2
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
..._record/connection_adapters/abstract/schema_statements.rb
+3
-2
activerecord/test/cases/migration/create_join_table_test.rb
activerecord/test/cases/migration/create_join_table_test.rb
+7
-0
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
浏览文件 @
62c01d3c
...
...
@@ -329,12 +329,13 @@ def create_join_table(table_1, table_2, options = {})
column_options
=
options
.
delete
(
:column_options
)
||
{}
column_options
.
reverse_merge!
(
null:
false
)
type
=
column_options
.
delete
(
:type
)
||
:integer
t1_column
,
t2_column
=
[
table_1
,
table_2
].
map
{
|
t
|
t
.
to_s
.
singularize
.
foreign_key
}
create_table
(
join_table_name
,
options
.
merge!
(
id:
false
))
do
|
td
|
td
.
integer
t1_column
,
column_options
td
.
integer
t2_column
,
column_options
td
.
send
type
,
t1_column
,
column_options
td
.
send
type
,
t2_column
,
column_options
yield
td
if
block_given?
end
end
...
...
activerecord/test/cases/migration/create_join_table_test.rb
浏览文件 @
62c01d3c
...
...
@@ -132,6 +132,13 @@ def test_create_and_drop_join_table_with_common_prefix
end
end
if
current_adapter?
(
:PostgreSQLAdapter
)
def
test_create_join_table_with_uuid
connection
.
create_join_table
:artists
,
:musics
,
column_options:
{
type: :uuid
}
assert_equal
[
:uuid
,
:uuid
],
connection
.
columns
(
:artists_musics
).
map
(
&
:type
)
end
end
private
def
with_table_cleanup
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录