Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c917fb7c
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,发现更多精彩内容 >>
提交
c917fb7c
编写于
5月 16, 2014
作者:
M
Matt Jones
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP: pass existing joins to construct_join_dependency
上级
654be5f0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
2 deletion
+31
-2
activerecord/lib/active_record/associations/alias_tracker.rb
activerecord/lib/active_record/associations/alias_tracker.rb
+11
-1
activerecord/lib/active_record/relation/finder_methods.rb
activerecord/lib/active_record/relation/finder_methods.rb
+10
-1
activerecord/test/cases/associations/inner_join_association_test.rb
...rd/test/cases/associations/inner_join_association_test.rb
+10
-0
未找到文件。
activerecord/lib/active_record/associations/alias_tracker.rb
浏览文件 @
c917fb7c
...
...
@@ -32,8 +32,18 @@ def self.initial_count_for(connection, name, table_joins)
join
.
left
.
downcase
.
scan
(
/join(?:\s+\w+)?\s+(\S+\s+)?
#{
quoted_name
}
\son/
).
size
els
e
els
if
join
.
respond_to?
:left
join
.
left
.
table_name
==
name
?
1
:
0
else
# this branch is reached by two tests:
#
# activerecord/test/cases/associations/cascaded_eager_loading_test.rb:37
# with :posts
#
# activerecord/test/cases/associations/eager_test.rb:1133
# with :comments
#
0
end
end
...
...
activerecord/lib/active_record/relation/finder_methods.rb
浏览文件 @
c917fb7c
...
...
@@ -336,7 +336,16 @@ def offset_index
end
def
find_with_associations
join_dependency
=
construct_join_dependency
# NOTE: the JoinDependency constructed here needs to know about
# any joins already present in `self`, so pass them in
#
# failing to do so means that in cases like activerecord/test/cases/associations/inner_join_association_test.rb:136
# incorrect SQL is generated. In that case, the join dependency for
# SpecialCategorizations is constructed without knowledge of the
# preexisting join in joins_values to categorizations (by way of
# the `has_many :through` for categories).
#
join_dependency
=
construct_join_dependency
(
joins_values
)
aliases
=
join_dependency
.
aliases
relation
=
select
aliases
.
columns
...
...
activerecord/test/cases/associations/inner_join_association_test.rb
浏览文件 @
c917fb7c
...
...
@@ -126,4 +126,14 @@ def test_find_with_conditions_on_through_reflection
categories
=
author
.
categories
.
includes
(
:special_categorizations
).
references
(
:special_categorizations
).
to_a
assert_equal
2
,
categories
.
size
end
test
"the correct records are loaded when including an aliased association"
do
author
=
Author
.
create!
name:
"Jon"
author
.
categories
.
create!
name:
'Not Special'
author
.
special_categories
.
create!
name:
'Special'
categories
=
author
.
categories
.
eager_load
(
:special_categorizations
).
order
(
:name
).
to_a
assert_equal
0
,
categories
.
first
.
special_categorizations
.
size
assert_equal
1
,
categories
.
second
.
special_categorizations
.
size
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录