Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
15426be1
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,发现更多精彩内容 >>
提交
15426be1
编写于
1月 27, 2020
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid making query when using `where(attr: out-of-range-value)`
Like as before Rails 6.0. Closes #38309.
上级
0d0c30e5
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
28 addition
and
8 deletion
+28
-8
activerecord/lib/active_record/relation/where_clause.rb
activerecord/lib/active_record/relation/where_clause.rb
+8
-1
activerecord/test/cases/calculations_test.rb
activerecord/test/cases/calculations_test.rb
+8
-4
activerecord/test/cases/finder_test.rb
activerecord/test/cases/finder_test.rb
+12
-3
未找到文件。
activerecord/lib/active_record/relation/where_clause.rb
浏览文件 @
15426be1
...
...
@@ -87,7 +87,14 @@ def self.empty
end
def
contradiction?
predicates
.
any?
{
|
x
|
Arel
::
Nodes
::
In
===
x
&&
Array
===
x
.
right
&&
x
.
right
.
empty?
}
predicates
.
any?
do
|
x
|
case
x
when
Arel
::
Nodes
::
In
Array
===
x
.
right
&&
x
.
right
.
empty?
when
Arel
::
Nodes
::
Equality
x
.
right
.
respond_to?
(
:unboundable?
)
&&
x
.
right
.
unboundable?
end
end
end
protected
...
...
activerecord/test/cases/calculations_test.rb
浏览文件 @
15426be1
...
...
@@ -905,15 +905,19 @@ def test_pluck_loaded_relation_sql_fragment
def
test_pick_one
assert_equal
"The First Topic"
,
Topic
.
order
(
:id
).
pick
(
:heading
)
assert_no_queries
do
assert_nil
Topic
.
none
.
pick
(
:heading
)
assert_nil
Topic
.
where
(
id:
9999999999999999999
).
pick
(
:heading
)
end
end
def
test_pick_two
assert_equal
[
"David"
,
"david@loudthinking.com"
],
Topic
.
order
(
:id
).
pick
(
:author_name
,
:author_email_address
)
assert_no_queries
do
assert_nil
Topic
.
none
.
pick
(
:author_name
,
:author_email_address
)
assert_nil
Topic
.
where
(
id:
9999999999999999999
).
pick
(
:author_name
,
:author_email_address
)
end
end
def
test_pick_delegate_to_all
cool_first
=
minivans
(
:cool_first
)
...
...
activerecord/test/cases/finder_test.rb
浏览文件 @
15426be1
...
...
@@ -397,16 +397,25 @@ def test_find_by_ids_with_limit_and_offset
end
def
test_find_with_large_number
Topic
.
send
(
:load_schema
)
assert_no_queries
do
assert_raises
(
ActiveRecord
::
RecordNotFound
)
{
Topic
.
find
(
"9999999999999999999999999999999"
)
}
end
end
def
test_find_by_with_large_number
Topic
.
send
(
:load_schema
)
assert_no_queries
do
assert_nil
Topic
.
find_by
(
id:
"9999999999999999999999999999999"
)
end
end
def
test_find_by_id_with_large_number
Topic
.
send
(
:load_schema
)
assert_no_queries
do
assert_nil
Topic
.
find_by_id
(
"9999999999999999999999999999999"
)
end
end
def
test_find_on_relation_with_large_number
assert_raises
(
ActiveRecord
::
RecordNotFound
)
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录