Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f1217c60
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,发现更多精彩内容 >>
提交
f1217c60
编写于
7月 22, 2016
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
No need to cache collection proxies separately
Because merging the association scope was removed.
上级
d1e0f11b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
1 addition
and
17 deletion
+1
-17
activerecord/lib/active_record/associations/collection_association.rb
.../lib/active_record/associations/collection_association.rb
+1
-7
activerecord/test/cases/associations/has_many_associations_test.rb
...ord/test/cases/associations/has_many_associations_test.rb
+0
-5
activerecord/test/cases/associations_test.rb
activerecord/test/cases/associations_test.rb
+0
-5
未找到文件。
activerecord/lib/active_record/associations/collection_association.rb
浏览文件 @
f1217c60
...
...
@@ -38,13 +38,7 @@ def reader(force_reload = false)
reload
end
if
null_scope?
# Cache the proxy separately before the owner has an id
# or else a post-save proxy will still lack the id
@null_proxy
||=
CollectionProxy
.
create
(
klass
,
self
)
else
@proxy
||=
CollectionProxy
.
create
(
klass
,
self
)
end
CollectionProxy
.
create
(
klass
,
self
)
end
# Implements the writer method, e.g. foo.items= for Foo.has_many :items
...
...
activerecord/test/cases/associations/has_many_associations_test.rb
浏览文件 @
f1217c60
...
...
@@ -611,21 +611,16 @@ def test_finding_using_primary_key
def
test_update_all_on_association_accessed_before_save
firm
=
Firm
.
new
(
name:
"Firm"
)
clients_proxy_id
=
firm
.
clients
.
object_id
firm
.
clients
<<
Client
.
first
firm
.
save!
assert_equal
firm
.
clients
.
count
,
firm
.
clients
.
update_all
(
description:
"Great!"
)
assert_not_equal
clients_proxy_id
,
firm
.
clients
.
object_id
end
def
test_update_all_on_association_accessed_before_save_with_explicit_foreign_key
# We can use the same cached proxy object because the id is available for the scope
firm
=
Firm
.
new
(
name:
"Firm"
,
id:
100
)
clients_proxy_id
=
firm
.
clients
.
object_id
firm
.
clients
<<
Client
.
first
firm
.
save!
assert_equal
firm
.
clients
.
count
,
firm
.
clients
.
update_all
(
description:
"Great!"
)
assert_equal
clients_proxy_id
,
firm
.
clients
.
object_id
end
def
test_belongs_to_sanity
...
...
activerecord/test/cases/associations_test.rb
浏览文件 @
f1217c60
...
...
@@ -233,11 +233,6 @@ def test_scoped_allows_conditions
assert_equal
david
.
projects
,
david
.
projects
.
scope
end
test
"proxy object is cached"
do
david
=
developers
(
:david
)
assert
david
.
projects
.
equal?
(
david
.
projects
)
end
test
"inverses get set of subsets of the association"
do
man
=
Man
.
create
man
.
interests
.
create
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录