Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
33fcdfff
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,体验更适合开发者的 AI 搜索 >>
提交
33fcdfff
编写于
5月 08, 2014
作者:
C
Carlos Antonio da Silva
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14992 from fredwu/habtm_relation_size_calculation_fix
Habtm relation size calculation fix. Fixes #14913, Fixes #14914.
上级
7f1fd026
f045663d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
1 deletion
+30
-1
activerecord/CHANGELOG.md
activerecord/CHANGELOG.md
+9
-0
activerecord/lib/active_record/associations/has_many_through_association.rb
...ctive_record/associations/has_many_through_association.rb
+1
-1
activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
...associations/has_and_belongs_to_many_associations_test.rb
+18
-0
activerecord/test/models/developer.rb
activerecord/test/models/developer.rb
+2
-0
未找到文件。
activerecord/CHANGELOG.md
浏览文件 @
33fcdfff
*
Fixed HABTM's CollectionAssociation size calculation.
HABTM should fall back to using the normal CollectionAssociation's size
calculation if the collection is not cached or loaded.
Fixes #14913 and #14914.
*Fred Wu*
*
Return a non zero status when running
`rake db:migrate:status`
and migration table does
*
Return a non zero status when running
`rake db:migrate:status`
and migration table does
not exist.
not exist.
...
...
activerecord/lib/active_record/associations/has_many_through_association.rb
浏览文件 @
33fcdfff
...
@@ -23,7 +23,7 @@ def size
...
@@ -23,7 +23,7 @@ def size
elsif
loaded?
elsif
loaded?
target
.
size
target
.
size
else
else
count
super
end
end
end
end
...
...
activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
浏览文件 @
33fcdfff
...
@@ -217,6 +217,24 @@ def test_habtm_unique_order_preserved
...
@@ -217,6 +217,24 @@ def test_habtm_unique_order_preserved
assert_equal
developers
(
:poor_jamis
,
:jamis
,
:david
),
projects
(
:active_record
).
developers
assert_equal
developers
(
:poor_jamis
,
:jamis
,
:david
),
projects
(
:active_record
).
developers
end
end
def
test_habtm_collection_size_from_build
devel
=
Developer
.
create
(
"name"
=>
"Fred Wu"
)
devel
.
projects
<<
Project
.
create
(
"name"
=>
"Grimetime"
)
devel
.
projects
.
build
assert_equal
2
,
devel
.
projects
.
size
end
def
test_habtm_collection_size_from_params
devel
=
Developer
.
new
({
projects_attributes:
{
'0'
=>
{}
}
})
assert_equal
1
,
devel
.
projects
.
size
end
def
test_build
def
test_build
devel
=
Developer
.
find
(
1
)
devel
=
Developer
.
find
(
1
)
proj
=
assert_no_queries
{
devel
.
projects
.
build
(
"name"
=>
"Projekt"
)
}
proj
=
assert_no_queries
{
devel
.
projects
.
build
(
"name"
=>
"Projekt"
)
}
...
...
activerecord/test/models/developer.rb
浏览文件 @
33fcdfff
...
@@ -13,6 +13,8 @@ def find_most_recent
...
@@ -13,6 +13,8 @@ def find_most_recent
end
end
end
end
accepts_nested_attributes_for
:projects
has_and_belongs_to_many
:projects_extended_by_name
,
has_and_belongs_to_many
:projects_extended_by_name
,
->
{
extending
(
DeveloperProjectsAssociationExtension
)
},
->
{
extending
(
DeveloperProjectsAssociationExtension
)
},
:class_name
=>
"Project"
,
:class_name
=>
"Project"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录