Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
30fd30e7
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 搜索 >>
提交
30fd30e7
编写于
3月 20, 2017
作者:
R
Rafael França
提交者:
GitHub
3月 20, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #28473 from kamipo/delegate_uniq_to_records
Delegate `uniq` to `records`
上级
d4c3db0d
59db5f22
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
20 deletion
+20
-20
activerecord/lib/active_record/relation/delegation.rb
activerecord/lib/active_record/relation/delegation.rb
+1
-1
activerecord/test/cases/associations/has_many_associations_test.rb
...ord/test/cases/associations/has_many_associations_test.rb
+3
-3
activerecord/test/cases/relations_test.rb
activerecord/test/cases/relations_test.rb
+7
-7
activerecord/test/cases/scoping/named_scoping_test.rb
activerecord/test/cases/scoping/named_scoping_test.rb
+9
-9
未找到文件。
activerecord/lib/active_record/relation/delegation.rb
浏览文件 @
30fd30e7
...
...
@@ -36,7 +36,7 @@ def inherited(child_class)
# may vary depending on the klass of a relation, so we create a subclass of Relation
# for each different klass, and the delegations are compiled into that subclass only.
delegate
:to_xml
,
:encode_with
,
:length
,
:
collect
,
:uniq
,
:each
,
:all?
,
:include?
,
:to_ary
,
:join
,
delegate
:to_xml
,
:encode_with
,
:length
,
:
each
,
:uniq
,
:to_ary
,
:join
,
:[]
,
:&
,
:|
,
:
+
,
:
-
,
:sample
,
:reverse
,
:compact
,
:in_groups
,
:in_groups_of
,
:to_sentence
,
:to_formatted_s
,
:as_json
,
:shuffle
,
:split
,
:index
,
to: :records
...
...
activerecord/test/cases/associations/has_many_associations_test.rb
浏览文件 @
30fd30e7
...
...
@@ -1903,7 +1903,7 @@ def test_calling_many_should_count_instead_of_loading_association
def
test_calling_many_on_loaded_association_should_not_use_query
firm
=
companies
(
:first_firm
)
firm
.
clients
.
collect
# force load
firm
.
clients
.
load
# force load
assert_no_queries
{
assert
firm
.
clients
.
many?
}
end
...
...
@@ -1942,7 +1942,7 @@ def test_calling_none_should_count_instead_of_loading_association
def
test_calling_none_on_loaded_association_should_not_use_query
firm
=
companies
(
:first_firm
)
firm
.
clients
.
collect
# force load
firm
.
clients
.
load
# force load
assert_no_queries
{
assert
!
firm
.
clients
.
none?
}
end
...
...
@@ -1977,7 +1977,7 @@ def test_calling_one_should_count_instead_of_loading_association
def
test_calling_one_on_loaded_association_should_not_use_query
firm
=
companies
(
:first_firm
)
firm
.
clients
.
collect
# force load
firm
.
clients
.
load
# force load
assert_no_queries
{
assert
!
firm
.
clients
.
one?
}
end
...
...
activerecord/test/cases/relations_test.rb
浏览文件 @
30fd30e7
...
...
@@ -112,7 +112,7 @@ def test_scoped_first
def
test_loaded_first
topics
=
Topic
.
all
.
order
(
"id ASC"
)
topics
.
to_a
# force load
topics
.
load
# force load
assert_no_queries
do
assert_equal
"The First Topic"
,
topics
.
first
.
title
...
...
@@ -123,7 +123,7 @@ def test_loaded_first
def
test_loaded_first_with_limit
topics
=
Topic
.
all
.
order
(
"id ASC"
)
topics
.
to_a
# force load
topics
.
load
# force load
assert_no_queries
do
assert_equal
[
"The First Topic"
,
...
...
@@ -136,7 +136,7 @@ def test_loaded_first_with_limit
def
test_first_get_more_than_available
topics
=
Topic
.
all
.
order
(
"id ASC"
)
unloaded_first
=
topics
.
first
(
10
)
topics
.
to_a
# force load
topics
.
load
# force load
assert_no_queries
do
loaded_first
=
topics
.
first
(
10
)
...
...
@@ -1155,7 +1155,7 @@ def test_size
assert
!
posts
.
loaded?
best_posts
=
posts
.
where
(
comments_count:
0
)
best_posts
.
to_a
# force load
best_posts
.
load
# force load
assert_no_queries
{
assert_equal
9
,
best_posts
.
size
}
end
...
...
@@ -1166,7 +1166,7 @@ def test_size_with_limit
assert
!
posts
.
loaded?
best_posts
=
posts
.
where
(
comments_count:
0
)
best_posts
.
to_a
# force load
best_posts
.
load
# force load
assert_no_queries
{
assert_equal
9
,
best_posts
.
size
}
end
...
...
@@ -1176,7 +1176,7 @@ def test_size_with_zero_limit
assert_no_queries
{
assert_equal
0
,
posts
.
size
}
assert
!
posts
.
loaded?
posts
.
to_a
# force load
posts
.
load
# force load
assert_no_queries
{
assert_equal
0
,
posts
.
size
}
end
...
...
@@ -1205,7 +1205,7 @@ def test_empty
assert
!
no_posts
.
loaded?
best_posts
=
posts
.
where
(
comments_count:
0
)
best_posts
.
to_a
# force load
best_posts
.
load
# force load
assert_no_queries
{
assert_equal
false
,
best_posts
.
empty?
}
end
...
...
activerecord/test/cases/scoping/named_scoping_test.rb
浏览文件 @
30fd30e7
...
...
@@ -23,8 +23,8 @@ def test_found_items_are_cached
all_posts
=
Topic
.
base
assert_queries
(
1
)
do
all_posts
.
collect
all_posts
.
collect
all_posts
.
collect
{
true
}
all_posts
.
collect
{
true
}
end
end
...
...
@@ -167,7 +167,7 @@ def test_first_and_last_should_allow_integers_for_limit
def
test_first_and_last_should_not_use_query_when_results_are_loaded
topics
=
Topic
.
base
topics
.
re
load
# force load
topics
.
load
# force load
assert_no_queries
do
topics
.
first
topics
.
last
...
...
@@ -178,7 +178,7 @@ def test_empty_should_not_load_results
topics
=
Topic
.
base
assert_queries
(
2
)
do
topics
.
empty?
# use count query
topics
.
collect
# force load
topics
.
load
# force load
topics
.
empty?
# use loaded (no query)
end
end
...
...
@@ -187,7 +187,7 @@ def test_any_should_not_load_results
topics
=
Topic
.
base
assert_queries
(
2
)
do
topics
.
any?
# use count query
topics
.
collect
# force load
topics
.
load
# force load
topics
.
any?
# use loaded (no query)
end
end
...
...
@@ -203,7 +203,7 @@ def test_any_should_call_proxy_found_if_using_a_block
def
test_any_should_not_fire_query_if_scope_loaded
topics
=
Topic
.
base
topics
.
collect
# force load
topics
.
load
# force load
assert_no_queries
{
assert
topics
.
any?
}
end
...
...
@@ -217,7 +217,7 @@ def test_many_should_not_load_results
topics
=
Topic
.
base
assert_queries
(
2
)
do
topics
.
many?
# use count query
topics
.
collect
# force load
topics
.
load
# force load
topics
.
many?
# use loaded (no query)
end
end
...
...
@@ -233,7 +233,7 @@ def test_many_should_call_proxy_found_if_using_a_block
def
test_many_should_not_fire_query_if_scope_loaded
topics
=
Topic
.
base
topics
.
collect
# force load
topics
.
load
# force load
assert_no_queries
{
assert
topics
.
many?
}
end
...
...
@@ -384,7 +384,7 @@ def test_size_should_use_count_when_results_are_not_loaded
def
test_size_should_use_length_when_results_are_loaded
topics
=
Topic
.
base
topics
.
re
load
# force load
topics
.
load
# force load
assert_no_queries
do
topics
.
size
# use loaded (no query)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录