Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
9f37f335
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,发现更多精彩内容 >>
提交
9f37f335
编写于
4月 08, 2012
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5718 from benedikt/master
Removes caching from ActiveRecord::Core::ClassMethods#relation
上级
e4f911aa
402576b0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
6 deletion
+13
-6
activerecord/lib/active_record/core.rb
activerecord/lib/active_record/core.rb
+3
-4
activerecord/lib/active_record/scoping/named.rb
activerecord/lib/active_record/scoping/named.rb
+2
-2
activerecord/test/cases/associations/eager_test.rb
activerecord/test/cases/associations/eager_test.rb
+6
-0
activerecord/test/models/comment.rb
activerecord/test/models/comment.rb
+2
-0
未找到文件。
activerecord/lib/active_record/core.rb
浏览文件 @
9f37f335
...
...
@@ -137,12 +137,12 @@ def arel_engine
private
def
relation
#:nodoc:
@relation
||
=
Relation
.
new
(
self
,
arel_table
)
relation
=
Relation
.
new
(
self
,
arel_table
)
if
finder_needs_type_condition?
@
relation
.
where
(
type_condition
).
create_with
(
inheritance_column
.
to_sym
=>
sti_name
)
relation
.
where
(
type_condition
).
create_with
(
inheritance_column
.
to_sym
=>
sti_name
)
else
@
relation
relation
end
end
end
...
...
@@ -351,7 +351,6 @@ def init_internals
@attributes
[
pk
]
=
nil
unless
@attributes
.
key?
(
pk
)
@relation
=
nil
@aggregation_cache
=
{}
@association_cache
=
{}
@attributes_cache
=
{}
...
...
activerecord/lib/active_record/scoping/named.rb
浏览文件 @
9f37f335
...
...
@@ -35,7 +35,7 @@ def scoped(options = nil)
if
current_scope
current_scope
.
clone
else
scope
=
relation
.
clone
scope
=
relation
scope
.
default_scoped
=
true
scope
end
...
...
@@ -49,7 +49,7 @@ def scope_attributes # :nodoc:
if
current_scope
current_scope
.
scope_for_create
else
scope
=
relation
.
clone
scope
=
relation
scope
.
default_scoped
=
true
scope
.
scope_for_create
end
...
...
activerecord/test/cases/associations/eager_test.rb
浏览文件 @
9f37f335
...
...
@@ -1174,6 +1174,12 @@ def test_deep_including_through_habtm
assert_equal
Comment
.
find
(
1
),
Comment
.
preload
(
:post
=>
:comments
).
scoping
{
Comment
.
find
(
1
)
}
end
test
"circular preload does not modify unscoped"
do
expected
=
FirstPost
.
unscoped
.
find
(
2
)
FirstPost
.
preload
(
:comments
=>
:first_post
).
find
(
1
)
assert_equal
expected
,
FirstPost
.
unscoped
.
find
(
2
)
end
test
"preload ignores the scoping"
do
assert_equal
(
Comment
.
find
(
1
).
post
,
...
...
activerecord/test/models/comment.rb
浏览文件 @
9f37f335
...
...
@@ -9,6 +9,8 @@ class Comment < ActiveRecord::Base
belongs_to
:post
,
:counter_cache
=>
true
has_many
:ratings
belongs_to
:first_post
,
:foreign_key
=>
:post_id
has_many
:children
,
:class_name
=>
'Comment'
,
:foreign_key
=>
:parent_id
belongs_to
:parent
,
:class_name
=>
'Comment'
,
:counter_cache
=>
:children_count
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录