Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
bbbe9cfc
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,发现更多精彩内容 >>
提交
bbbe9cfc
编写于
12月 04, 2014
作者:
S
Sean Griffin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17919 from mrgilman/stop-supporting-nested-arrays
Remove deprecated behavior allowing nested arrays as query values
上级
d1f003e6
be6897e3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
5 addition
and
40 deletion
+5
-40
activerecord/CHANGELOG.md
activerecord/CHANGELOG.md
+5
-0
activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
...active_record/relation/predicate_builder/array_handler.rb
+0
-10
activerecord/test/cases/finder_test.rb
activerecord/test/cases/finder_test.rb
+0
-24
activerecord/test/cases/relation/where_test.rb
activerecord/test/cases/relation/where_test.rb
+0
-6
未找到文件。
activerecord/CHANGELOG.md
浏览文件 @
bbbe9cfc
*
Remove deprecated behavior allowing nested arrays to be passed as query
values.
*Melanie Gilman*
*
Deprecate passing a class as a value in a query. Users should pass strings
instead.
...
...
activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
浏览文件 @
bbbe9cfc
...
...
@@ -7,16 +7,6 @@ def call(attribute, value)
values
=
value
.
map
{
|
x
|
x
.
is_a?
(
Base
)
?
x
.
id
:
x
}
nils
,
values
=
values
.
partition
(
&
:nil?
)
if
values
.
any?
{
|
val
|
val
.
is_a?
(
Array
)
}
ActiveSupport
::
Deprecation
.
warn
(
<<-
MSG
.
squish
)
Passing a nested array to Active Record finder methods is
deprecated and will be removed. Flatten your array before using
it for 'IN' conditions.
MSG
values
=
values
.
flatten
end
return
attribute
.
in
([])
if
values
.
empty?
&&
nils
.
empty?
ranges
,
values
=
values
.
partition
{
|
v
|
v
.
is_a?
(
Range
)
}
...
...
activerecord/test/cases/finder_test.rb
浏览文件 @
bbbe9cfc
...
...
@@ -546,30 +546,6 @@ def test_find_on_hash_conditions_with_array_of_ranges
assert_equal
[
1
,
2
,
6
,
7
,
8
],
Comment
.
where
(
id:
[
1
..
2
,
6
..
8
]).
to_a
.
map
(
&
:id
).
sort
end
def
test_find_on_hash_conditions_with_nested_array_of_integers_and_ranges
assert_deprecated
do
assert_equal
[
1
,
2
,
3
,
5
,
6
,
7
,
8
,
9
],
Comment
.
where
(
id:
[[
1
..
2
],
3
,
[
5
],
6
..
8
,
9
]).
to_a
.
map
(
&
:id
).
sort
end
end
def
test_find_on_hash_conditions_with_array_of_integers_and_arrays
assert_deprecated
do
assert_equal
[
1
,
2
,
3
,
5
,
6
,
7
,
8
,
9
],
Comment
.
where
(
id:
[[
1
,
2
],
3
,
5
,
[
6
,
[
7
],
8
],
9
]).
to_a
.
map
(
&
:id
).
sort
end
end
def
test_find_on_hash_conditions_with_nested_array_of_integers_and_ranges_and_nils
assert_deprecated
do
assert_equal
[
1
,
3
,
4
,
5
],
Topic
.
where
(
parent_id:
[[
2
..
6
],
nil
]).
to_a
.
map
(
&
:id
).
sort
end
end
def
test_find_on_hash_conditions_with_nested_array_of_integers_and_ranges_and_more_nils
assert_deprecated
do
assert_equal
[],
Topic
.
where
(
parent_id:
[[
7
..
10
,
nil
,
[
nil
]],
[
nil
]]).
to_a
.
map
(
&
:id
).
sort
end
end
def
test_find_on_multiple_hash_conditions
assert
Topic
.
where
(
author_name:
"David"
,
title:
"The First Topic"
,
replies_count:
1
,
approved:
false
).
find
(
1
)
assert_raise
(
ActiveRecord
::
RecordNotFound
)
{
Topic
.
where
(
author_name:
"David"
,
title:
"The First Topic"
,
replies_count:
1
,
approved:
true
).
find
(
1
)
}
...
...
activerecord/test/cases/relation/where_test.rb
浏览文件 @
bbbe9cfc
...
...
@@ -181,12 +181,6 @@ def test_where_with_table_name_and_empty_array
assert_equal
0
,
Post
.
where
(
:id
=>
[]).
count
end
def
test_where_with_table_name_and_nested_empty_array
assert_deprecated
do
assert_equal
[],
Post
.
where
(
:id
=>
[[]]).
to_a
end
end
def
test_where_with_empty_hash_and_no_foreign_key
assert_equal
0
,
Edge
.
where
(
:sink
=>
{}).
count
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录