Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
8c65abe5
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 搜索 >>
提交
8c65abe5
编写于
6月 28, 2017
作者:
R
Rafael França
提交者:
GitHub
6月 28, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #29405 from kamipo/locked_should_not_build_arel
`Relation#locked?` should not build arel
上级
97d276bf
425f2cac
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
13 addition
and
9 deletion
+13
-9
activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
...active_record/connection_adapters/abstract/query_cache.rb
+1
-0
activerecord/lib/active_record/relation.rb
activerecord/lib/active_record/relation.rb
+1
-1
activerecord/lib/active_record/relation/calculations.rb
activerecord/lib/active_record/relation/calculations.rb
+1
-1
activerecord/lib/active_record/relation/delegation.rb
activerecord/lib/active_record/relation/delegation.rb
+0
-2
activerecord/lib/active_record/relation/finder_methods.rb
activerecord/lib/active_record/relation/finder_methods.rb
+3
-5
activerecord/test/cases/relations_test.rb
activerecord/test/cases/relations_test.rb
+6
-0
activerecord/test/models/post.rb
activerecord/test/models/post.rb
+1
-0
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
浏览文件 @
8c65abe5
...
...
@@ -123,6 +123,7 @@ def cache_sql(sql, name, binds)
# If arel is locked this is a SELECT ... FOR UPDATE or somesuch. Such
# queries should not be cached.
def
locked?
(
arel
)
arel
=
arel
.
arel
if
arel
.
is_a?
(
Relation
)
arel
.
respond_to?
(
:locked
)
&&
arel
.
locked
end
...
...
activerecord/lib/active_record/relation.rb
浏览文件 @
8c65abe5
...
...
@@ -18,7 +18,7 @@ class Relation
attr_reader
:table
,
:klass
,
:loaded
,
:predicate_builder
alias
:model
:klass
alias
:loaded?
:loaded
alias
:locked?
:lock
ed
alias
:locked?
:lock
_value
def
initialize
(
klass
,
table
,
predicate_builder
,
values
=
{})
@klass
=
klass
...
...
activerecord/lib/active_record/relation/calculations.rb
浏览文件 @
8c65abe5
...
...
@@ -311,7 +311,7 @@ def execute_grouped_calculation(operation, column_name, distinct) #:nodoc:
relation
.
group_values
=
group_fields
relation
.
select_values
=
select_values
calculated_data
=
@klass
.
connection
.
select_all
(
relation
,
nil
,
relation
.
bound_attributes
)
calculated_data
=
@klass
.
connection
.
select_all
(
relation
.
arel
,
nil
,
relation
.
bound_attributes
)
if
association
key_ids
=
calculated_data
.
collect
{
|
row
|
row
[
group_aliases
.
first
]
}
...
...
activerecord/lib/active_record/relation/delegation.rb
浏览文件 @
8c65abe5
...
...
@@ -44,8 +44,6 @@ def inherited(child_class)
delegate
:table_name
,
:quoted_table_name
,
:primary_key
,
:quoted_primary_key
,
:connection
,
:columns_hash
,
to: :klass
delegate
:ast
,
:locked
,
to: :arel
module
ClassSpecificRelation
# :nodoc:
extend
ActiveSupport
::
Concern
...
...
activerecord/lib/active_record/relation/finder_methods.rb
浏览文件 @
8c65abe5
...
...
@@ -315,7 +315,7 @@ def exists?(conditions = :none)
relation
=
construct_relation_for_exists
(
relation
,
conditions
)
connection
.
select_value
(
relation
,
"
#{
name
}
Exists"
,
relation
.
bound_attributes
)
?
true
:
false
connection
.
select_value
(
relation
.
arel
,
"
#{
name
}
Exists"
,
relation
.
bound_attributes
)
?
true
:
false
rescue
::
RangeError
false
end
...
...
@@ -376,8 +376,7 @@ def find_with_associations
if
ActiveRecord
::
NullRelation
===
relation
[]
else
arel
=
relation
.
arel
rows
=
connection
.
select_all
(
arel
,
"SQL"
,
relation
.
bound_attributes
)
rows
=
connection
.
select_all
(
relation
.
arel
,
"SQL"
,
relation
.
bound_attributes
)
join_dependency
.
instantiate
(
rows
,
aliases
)
end
end
...
...
@@ -424,9 +423,8 @@ def limited_ids_for(relation)
"
#{
quoted_table_name
}
.
#{
quoted_primary_key
}
"
,
relation
.
order_values
)
relation
=
relation
.
except
(
:select
).
select
(
values
).
distinct!
arel
=
relation
.
arel
id_rows
=
@klass
.
connection
.
select_all
(
arel
,
"SQL"
,
relation
.
bound_attributes
)
id_rows
=
@klass
.
connection
.
select_all
(
relation
.
arel
,
"SQL"
,
relation
.
bound_attributes
)
id_rows
.
map
{
|
row
|
row
[
primary_key
]
}
end
...
...
activerecord/test/cases/relations_test.rb
浏览文件 @
8c65abe5
...
...
@@ -2007,6 +2007,12 @@ def test_merging_keeps_lhs_binds
assert_equal
binds
,
merged
.
bound_attributes
end
def
test_locked_should_not_build_arel
posts
=
Post
.
locked
assert
posts
.
locked?
assert_nothing_raised
{
posts
.
lock!
(
false
)
}
end
def
test_relation_join_method
assert_equal
"Thank you for the welcome,Thank you again for the welcome"
,
Post
.
first
.
comments
.
join
(
","
)
end
...
...
activerecord/test/models/post.rb
浏览文件 @
8c65abe5
...
...
@@ -22,6 +22,7 @@ def greeting
scope
:ranked_by_comments
,
->
{
order
(
"comments_count DESC"
)
}
scope
:limit_by
,
lambda
{
|
l
|
limit
(
l
)
}
scope
:locked
,
->
{
lock
}
belongs_to
:author
belongs_to
:readonly_author
,
->
{
readonly
},
class_name:
"Author"
,
foreign_key: :author_id
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录