Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
3fda3f9d
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 搜索 >>
未验证
提交
3fda3f9d
编写于
8月 20, 2019
作者:
M
Matthew Draper
提交者:
Rafael Mendonça França
8月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request #36985 from anmolarora/fix-take-memoization
Clear ActiveRecord object memoized by take
上级
70e6ff2e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
1 deletion
+27
-1
activerecord/lib/active_record/relation.rb
activerecord/lib/active_record/relation.rb
+1
-0
activerecord/test/cases/relation/where_test.rb
activerecord/test/cases/relation/where_test.rb
+0
-1
activerecord/test/cases/relations_test.rb
activerecord/test/cases/relations_test.rb
+26
-0
未找到文件。
activerecord/lib/active_record/relation.rb
浏览文件 @
3fda3f9d
...
...
@@ -629,6 +629,7 @@ def reset
@to_sql
=
@arel
=
@loaded
=
@should_eager_load
=
nil
@records
=
[].
freeze
@offsets
=
{}
@take
=
nil
self
end
...
...
activerecord/test/cases/relation/where_test.rb
浏览文件 @
3fda3f9d
...
...
@@ -390,7 +390,6 @@ def test_where_with_relation_on_has_one_association
assert_equal
author_addresses
(
:david_address
),
author_address
end
def
test_where_on_association_with_select_relation
essay
=
Essay
.
where
(
author:
Author
.
where
(
name:
"David"
).
select
(
:name
)).
take
assert_equal
essays
(
:david_modest_proposal
),
essay
...
...
activerecord/test/cases/relations_test.rb
浏览文件 @
3fda3f9d
...
...
@@ -2043,6 +2043,32 @@ def test_relation_with_private_kernel_method
assert_equal
[
accounts
(
:signals37
)],
sub_accounts
.
available
end
def
test_where_with_take_memoization
5
.
times
do
|
idx
|
Post
.
create!
(
title:
idx
.
to_s
,
body:
idx
.
to_s
)
end
posts
=
Post
.
all
first_post
=
posts
.
take
third_post
=
posts
.
where
(
title:
"3"
).
take
assert_equal
"3"
,
third_post
.
title
assert_not_equal
first_post
.
object_id
,
third_post
.
object_id
end
def
test_find_by_with_take_memoization
5
.
times
do
|
idx
|
Post
.
create!
(
title:
idx
.
to_s
,
body:
idx
.
to_s
)
end
posts
=
Post
.
all
first_post
=
posts
.
take
third_post
=
posts
.
find_by
(
title:
"3"
)
assert_equal
"3"
,
third_post
.
title
assert_not_equal
first_post
.
object_id
,
third_post
.
object_id
end
test
"#skip_query_cache!"
do
Post
.
cache
do
assert_queries
(
1
)
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录