Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
673dbaba
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 搜索 >>
未验证
提交
673dbaba
编写于
5月 15, 2020
作者:
A
Aaron Patterson
提交者:
GitHub
5月 15, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #39288 from Edouard-chin/ec-homogeousin-where-values
Fix `AR::Relation#where_values_hash` with `HomogeousIn`:
上级
35bf86fe
db0469bf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
7 deletion
+17
-7
activerecord/lib/active_record/relation/where_clause.rb
activerecord/lib/active_record/relation/where_clause.rb
+2
-3
activerecord/lib/arel/nodes/homogeneous_in.rb
activerecord/lib/arel/nodes/homogeneous_in.rb
+4
-0
activerecord/lib/arel/predications.rb
activerecord/lib/arel/predications.rb
+4
-4
activerecord/test/cases/relation_test.rb
activerecord/test/cases/relation_test.rb
+7
-0
未找到文件。
activerecord/lib/active_record/relation/where_clause.rb
浏览文件 @
673dbaba
...
...
@@ -119,10 +119,9 @@ def equalities(predicates)
equalities
=
[]
predicates
.
each
do
|
node
|
case
node
when
Arel
::
Nodes
::
Equality
if
equality_node?
(
node
)
equalities
<<
node
when
Arel
::
Nodes
::
And
elsif
node
.
is_a?
(
Arel
::
Nodes
::
And
)
equalities
.
concat
equalities
(
node
.
children
)
end
end
...
...
activerecord/lib/arel/nodes/homogeneous_in.rb
浏览文件 @
673dbaba
...
...
@@ -32,6 +32,10 @@ def left
attribute
end
def
right
attribute
.
quoted_array
(
values
)
end
def
table_name
attribute
.
relation
.
table_alias
||
attribute
.
relation
.
name
end
...
...
activerecord/lib/arel/predications.rb
浏览文件 @
673dbaba
...
...
@@ -214,6 +214,10 @@ def overlaps(other)
Arel
::
Nodes
::
Overlaps
.
new
(
self
,
other
)
end
def
quoted_array
(
others
)
others
.
map
{
|
v
|
quoted_node
(
v
)
}
end
private
def
grouping_any
(
method_id
,
others
,
*
extras
)
nodes
=
others
.
map
{
|
expr
|
send
(
method_id
,
expr
,
*
extras
)
}
...
...
@@ -231,10 +235,6 @@ def quoted_node(other)
Nodes
.
build_quoted
(
other
,
self
)
end
def
quoted_array
(
others
)
others
.
map
{
|
v
|
quoted_node
(
v
)
}
end
def
infinity?
(
value
)
value
.
respond_to?
(
:infinite?
)
&&
value
.
infinite?
end
...
...
activerecord/test/cases/relation_test.rb
浏览文件 @
673dbaba
...
...
@@ -52,6 +52,13 @@ def test_empty_where_values_hash
assert_equal
({},
relation
.
where_values_hash
)
end
def
test_where_values_hash_with_in_clause
relation
=
Relation
.
new
(
Post
)
relation
.
where!
(
title:
[
"foo"
,
"bar"
,
"hello"
])
assert_equal
({
"title"
=>
[
"foo"
,
"bar"
,
"hello"
]
},
relation
.
where_values_hash
)
end
def
test_has_values
relation
=
Relation
.
new
(
Post
)
relation
.
where!
(
id:
10
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录