Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
04333482
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,发现更多精彩内容 >>
提交
04333482
编写于
3月 11, 2009
作者:
P
Pratik Naik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename ActiveRecord::Base.each to ActiveRecord::Base.find_each
上级
19ad375e
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
6 addition
and
7 deletion
+6
-7
activerecord/CHANGELOG
activerecord/CHANGELOG
+1
-2
activerecord/lib/active_record/batches.rb
activerecord/lib/active_record/batches.rb
+2
-2
activerecord/test/cases/batches_test.rb
activerecord/test/cases/batches_test.rb
+3
-3
未找到文件。
activerecord/CHANGELOG
浏览文件 @
04333482
*2.3.1 [RC2] (March 5, 2009)*
* Added ActiveRecord::Base.each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck]
* Added ActiveRecord::Base.
find_
each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck]
* Added that ActiveRecord::Base.exists? can be called with no arguments #1817 [Scott Taylor]
*2.3.0 [RC1] (February 1st, 2009)*
* Add Support for updating deeply nested models from a single form. #1202 [Eloy Duran]
...
...
activerecord/lib/active_record/batches.rb
浏览文件 @
04333482
...
...
@@ -11,14 +11,14 @@ module ClassMethods
#
# Example:
#
# Person.each(:conditions => "age > 21") do |person|
# Person.
find_
each(:conditions => "age > 21") do |person|
# person.party_all_night!
# end
#
# Note: This method is only intended to use for batch processing of large amounts of records that wouldn't fit in
# memory all at once. If you just need to loop over less than 1000 records, it's probably better just to use the
# regular find methods.
def
each
(
options
=
{})
def
find_
each
(
options
=
{})
find_in_batches
(
options
)
do
|
records
|
records
.
each
{
|
record
|
yield
record
}
end
...
...
activerecord/test/cases/batches_test.rb
浏览文件 @
04333482
...
...
@@ -11,7 +11,7 @@ def setup
def
test_each_should_excecute_one_query_per_batch
assert_queries
(
Post
.
count
+
1
)
do
Post
.
each
(
:batch_size
=>
1
)
do
|
post
|
Post
.
find_each
(
:batch_size
=>
1
)
do
|
post
|
assert_kind_of
Post
,
post
end
end
...
...
@@ -19,13 +19,13 @@ def test_each_should_excecute_one_query_per_batch
def
test_each_should_raise_if_the_order_is_set
assert_raise
(
RuntimeError
)
do
Post
.
each
(
:order
=>
"title"
)
{
|
post
|
post
}
Post
.
find_
each
(
:order
=>
"title"
)
{
|
post
|
post
}
end
end
def
test_each_should_raise_if_the_limit_is_set
assert_raise
(
RuntimeError
)
do
Post
.
each
(
:limit
=>
1
)
{
|
post
|
post
}
Post
.
find_
each
(
:limit
=>
1
)
{
|
post
|
post
}
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录