Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
ecb4e4b2
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,发现更多精彩内容 >>
提交
ecb4e4b2
编写于
9月 07, 2015
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21522 from tgxworld/scope_perf
PERF: Scope performance.
上级
8c34d106
52b2ab9e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
5 deletion
+13
-5
activerecord/lib/active_record/relation/predicate_builder.rb
activerecord/lib/active_record/relation/predicate_builder.rb
+2
-2
activerecord/lib/active_record/relation/predicate_builder/association_query_handler.rb
...d/relation/predicate_builder/association_query_handler.rb
+2
-2
activerecord/lib/active_record/relation/where_clause_factory.rb
...record/lib/active_record/relation/where_clause_factory.rb
+1
-0
activerecord/lib/active_record/scoping/default.rb
activerecord/lib/active_record/scoping/default.rb
+8
-1
未找到文件。
activerecord/lib/active_record/relation/predicate_builder.rb
浏览文件 @
ecb4e4b2
...
...
@@ -24,12 +24,12 @@ def initialize(table)
end
def
build_from_hash
(
attributes
)
attributes
=
convert_dot_notation_to_hash
(
attributes
.
stringify_keys
)
attributes
=
convert_dot_notation_to_hash
(
attributes
)
expand_from_hash
(
attributes
)
end
def
create_binds
(
attributes
)
attributes
=
convert_dot_notation_to_hash
(
attributes
.
stringify_keys
)
attributes
=
convert_dot_notation_to_hash
(
attributes
)
create_binds_for_hash
(
attributes
)
end
...
...
activerecord/lib/active_record/relation/predicate_builder/association_query_handler.rb
浏览文件 @
ecb4e4b2
...
...
@@ -10,10 +10,10 @@ def call(attribute, value)
table
=
value
.
associated_table
if
value
.
base_class
queries
[
table
.
association_foreign_type
]
=
value
.
base_class
.
name
queries
[
table
.
association_foreign_type
.
to_s
]
=
value
.
base_class
.
name
end
queries
[
table
.
association_foreign_key
]
=
value
.
ids
queries
[
table
.
association_foreign_key
.
to_s
]
=
value
.
ids
predicate_builder
.
build_from_hash
(
queries
)
end
...
...
activerecord/lib/active_record/relation/where_clause_factory.rb
浏览文件 @
ecb4e4b2
...
...
@@ -15,6 +15,7 @@ def build(opts, other)
when
Hash
attributes
=
predicate_builder
.
resolve_column_aliases
(
opts
)
attributes
=
klass
.
send
(
:expand_hash_conditions_for_aggregates
,
attributes
)
attributes
.
stringify_keys!
attributes
,
binds
=
predicate_builder
.
create_binds
(
attributes
)
...
...
activerecord/lib/active_record/scoping/default.rb
浏览文件 @
ecb4e4b2
...
...
@@ -6,8 +6,10 @@ module Default
included
do
# Stores the default scope for the class.
class_attribute
:default_scopes
,
instance_writer:
false
,
instance_predicate:
false
class_attribute
:default_scope_override
,
instance_predicate:
false
self
.
default_scopes
=
[]
self
.
default_scope_override
=
nil
end
module
ClassMethods
...
...
@@ -101,7 +103,12 @@ def default_scope(scope = nil)
def
build_default_scope
(
base_rel
=
nil
)
# :nodoc:
return
if
abstract_class?
if
!
Base
.
is_a?
(
method
(
:default_scope
).
owner
)
if
self
.
default_scope_override
.
nil?
self
.
default_scope_override
=
!
Base
.
is_a?
(
method
(
:default_scope
).
owner
)
end
if
self
.
default_scope_override
# The user has defined their own default scope method, so call that
evaluate_default_scope
{
default_scope
}
elsif
default_scopes
.
any?
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录