Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6746eea7
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 搜索 >>
未验证
提交
6746eea7
编写于
3月 07, 2019
作者:
R
Ryuta Kamizono
提交者:
GitHub
3月 07, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #35512 from kamipo/delegate_only
Delegate `only` query method to relation as with `except`
上级
60c953c9
83097062
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
2 deletion
+6
-2
activerecord/lib/active_record/querying.rb
activerecord/lib/active_record/querying.rb
+1
-1
activerecord/test/cases/relation/delegation_test.rb
activerecord/test/cases/relation/delegation_test.rb
+1
-1
activerecord/test/cases/relations_test.rb
activerecord/test/cases/relations_test.rb
+4
-0
未找到文件。
activerecord/lib/active_record/querying.rb
浏览文件 @
6746eea7
...
...
@@ -14,7 +14,7 @@ module Querying
:find_each
,
:find_in_batches
,
:in_batches
,
:select
,
:reselect
,
:order
,
:reorder
,
:group
,
:limit
,
:offset
,
:joins
,
:left_joins
,
:left_outer_joins
,
:where
,
:rewhere
,
:preload
,
:eager_load
,
:includes
,
:from
,
:lock
,
:readonly
,
:extending
,
:or
,
:having
,
:create_with
,
:distinct
,
:references
,
:none
,
:unscope
,
:merge
,
:except
,
:having
,
:create_with
,
:distinct
,
:references
,
:none
,
:unscope
,
:merge
,
:except
,
:only
,
:count
,
:average
,
:minimum
,
:maximum
,
:sum
,
:calculate
,
:pluck
,
:pick
,
:ids
].
freeze
# :nodoc:
...
...
activerecord/test/cases/relation/delegation_test.rb
浏览文件 @
6746eea7
...
...
@@ -48,7 +48,7 @@ class QueryingMethodsDelegationTest < ActiveRecord::TestCase
ActiveRecord
::
Batches
.
public_instance_methods
(
false
)
+
ActiveRecord
::
Calculations
.
public_instance_methods
(
false
)
+
ActiveRecord
::
FinderMethods
.
public_instance_methods
(
false
)
-
[
:raise_record_not_found_exception!
]
+
ActiveRecord
::
SpawnMethods
.
public_instance_methods
(
false
)
-
[
:spawn
,
:merge!
,
:only
]
+
ActiveRecord
::
SpawnMethods
.
public_instance_methods
(
false
)
-
[
:spawn
,
:merge!
]
+
ActiveRecord
::
QueryMethods
.
public_instance_methods
(
false
).
reject
{
|
method
|
method
.
to_s
.
end_with?
(
"="
,
"!"
,
"value"
,
"values"
,
"clause"
)
}
-
[
:reverse_order
,
:arel
,
:extensions
]
+
[
...
...
activerecord/test/cases/relations_test.rb
浏览文件 @
6746eea7
...
...
@@ -1503,9 +1503,11 @@ def test_except
author_posts
=
relation
.
except
(
:order
,
:limit
)
assert_equal
Post
.
where
(
author_id:
1
).
sort_by
(
&
:id
),
author_posts
.
sort_by
(
&
:id
)
assert_equal
author_posts
.
sort_by
(
&
:id
),
relation
.
scoping
{
Post
.
except
(
:order
,
:limit
).
sort_by
(
&
:id
)
}
all_posts
=
relation
.
except
(
:where
,
:order
,
:limit
)
assert_equal
Post
.
all
.
sort_by
(
&
:id
),
all_posts
.
sort_by
(
&
:id
)
assert_equal
all_posts
.
sort_by
(
&
:id
),
relation
.
scoping
{
Post
.
except
(
:where
,
:order
,
:limit
).
sort_by
(
&
:id
)
}
end
def
test_only
...
...
@@ -1514,9 +1516,11 @@ def test_only
author_posts
=
relation
.
only
(
:where
)
assert_equal
Post
.
where
(
author_id:
1
).
sort_by
(
&
:id
),
author_posts
.
sort_by
(
&
:id
)
assert_equal
author_posts
.
sort_by
(
&
:id
),
relation
.
scoping
{
Post
.
only
(
:where
).
sort_by
(
&
:id
)
}
all_posts
=
relation
.
only
(
:order
)
assert_equal
Post
.
order
(
"id ASC"
).
to_a
,
all_posts
.
to_a
assert_equal
all_posts
.
to_a
,
relation
.
scoping
{
Post
.
only
(
:order
).
to_a
}
end
def
test_anonymous_extension
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录