Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d3e64659
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,发现更多精彩内容 >>
未验证
提交
d3e64659
编写于
10月 24, 2018
作者:
R
Rafael França
提交者:
GitHub
10月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #34303 from kamipo/lazy_checking_boundable
Lazy checking whether or not values in IN clause are boundable
上级
eba2ba8d
ce40073c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
18 addition
and
9 deletion
+18
-9
activerecord/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb
...rd/connection_adapters/determine_if_preparable_visitor.rb
+10
-1
activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
...active_record/relation/predicate_builder/array_handler.rb
+2
-3
activerecord/test/cases/associations/eager_test.rb
activerecord/test/cases/associations/eager_test.rb
+1
-1
activerecord/test/cases/bind_parameter_test.rb
activerecord/test/cases/bind_parameter_test.rb
+1
-1
activerecord/test/fixtures/citations.yml
activerecord/test/fixtures/citations.yml
+1
-0
activerecord/test/schema/schema.rb
activerecord/test/schema/schema.rb
+3
-3
未找到文件。
activerecord/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb
浏览文件 @
d3e64659
...
...
@@ -10,8 +10,17 @@ def accept(*)
super
end
def
visit_Arel_Nodes_In
(
*
)
def
visit_Arel_Nodes_In
(
o
,
collector
)
@preparable
=
false
if
Array
===
o
.
right
&&
!
o
.
right
.
empty?
o
.
right
.
delete_if
do
|
bind
|
if
Arel
::
Nodes
::
BindParam
===
bind
&&
Relation
::
QueryAttribute
===
bind
.
value
!
bind
.
value
.
boundable?
end
end
end
super
end
...
...
activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
浏览文件 @
d3e64659
...
...
@@ -22,9 +22,8 @@ def call(attribute, value)
when
1
then
predicate_builder
.
build
(
attribute
,
values
.
first
)
else
values
.
map!
do
|
v
|
bind
=
predicate_builder
.
build_bind_attribute
(
attribute
.
name
,
v
)
bind
if
bind
.
value
.
boundable?
end
.
compact!
predicate_builder
.
build_bind_attribute
(
attribute
.
name
,
v
)
end
values
.
empty?
?
NullPredicate
:
attribute
.
in
(
values
)
end
...
...
activerecord/test/cases/associations/eager_test.rb
浏览文件 @
d3e64659
...
...
@@ -34,7 +34,7 @@ class EagerLoadingTooManyIdsTest < ActiveRecord::TestCase
fixtures
:citations
def
test_preloading_too_many_ids
assert_equal
Citation
.
count
,
Citation
.
preload
(
:
citations
).
to_a
.
size
assert_equal
Citation
.
count
,
Citation
.
preload
(
:
reference_of
).
to_a
.
size
end
def
test_eager_loading_too_may_ids
...
...
activerecord/test/cases/bind_parameter_test.rb
浏览文件 @
d3e64659
...
...
@@ -36,7 +36,7 @@ def teardown
def
test_too_many_binds
bind_params_length
=
@connection
.
send
(
:bind_params_length
)
topics
=
Topic
.
where
(
id:
(
1
..
bind_params_length
+
1
).
to_a
)
topics
=
Topic
.
where
(
id:
(
1
..
bind_params_length
).
to_a
<<
2
**
63
)
assert_equal
Topic
.
count
,
topics
.
count
end
...
...
activerecord/test/fixtures/citations.yml
浏览文件 @
d3e64659
<% 65536.times do |i| %>
fixture_no_<%= i %>
:
id
:
<%= i %>
book2_id
:
<%= i*i %>
<% end %>
activerecord/test/schema/schema.rb
浏览文件 @
d3e64659
...
...
@@ -93,7 +93,7 @@
t
.
integer
:pirate_id
end
create_table
:books
,
force:
true
do
|
t
|
create_table
:books
,
id: :integer
,
force:
true
do
|
t
|
t
.
references
:author
t
.
string
:format
t
.
column
:name
,
:string
...
...
@@ -158,8 +158,8 @@
end
create_table
:citations
,
force:
true
do
|
t
|
t
.
column
:book1_id
,
:integer
t
.
column
:book2_id
,
:integer
t
.
references
:book1
t
.
references
:book2
t
.
references
:citation
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录