Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c83f28ff
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,发现更多精彩内容 >>
提交
c83f28ff
编写于
9月 30, 2017
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure `AliasTracker` respects a custom table name
上级
5349f231
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
6 deletion
+10
-6
activerecord/lib/active_record/associations/association_scope.rb
...ecord/lib/active_record/associations/association_scope.rb
+1
-1
activerecord/lib/active_record/associations/join_dependency.rb
...erecord/lib/active_record/associations/join_dependency.rb
+1
-1
activerecord/test/cases/relations_test.rb
activerecord/test/cases/relations_test.rb
+8
-4
未找到文件。
activerecord/lib/active_record/associations/association_scope.rb
浏览文件 @
c83f28ff
...
...
@@ -23,7 +23,7 @@ def scope(association)
reflection
=
association
.
reflection
scope
=
klass
.
unscoped
owner
=
association
.
owner
alias_tracker
=
AliasTracker
.
create
(
klass
.
connection
,
klass
.
table_
name
)
alias_tracker
=
AliasTracker
.
create
(
klass
.
connection
,
scope
.
table
.
name
)
chain
=
get_chain
(
reflection
,
association
,
alias_tracker
)
scope
.
extending!
reflection
.
extensions
...
...
activerecord/lib/active_record/associations/join_dependency.rb
浏览文件 @
c83f28ff
...
...
@@ -91,7 +91,7 @@ def self.walk_tree(associations, hash)
# joins # => []
#
def
initialize
(
base
,
table
,
associations
,
joins
,
eager_loading:
true
)
@alias_tracker
=
AliasTracker
.
create_with_joins
(
base
.
connection
,
base
.
table_
name
,
joins
)
@alias_tracker
=
AliasTracker
.
create_with_joins
(
base
.
connection
,
table
.
name
,
joins
)
@eager_loading
=
eager_loading
tree
=
self
.
class
.
make_tree
associations
@join_root
=
JoinBase
.
new
(
base
,
table
,
build
(
tree
,
base
))
...
...
activerecord/test/cases/relations_test.rb
浏览文件 @
c83f28ff
...
...
@@ -19,12 +19,12 @@
require
"models/minivan"
require
"models/possession"
require
"models/reader"
require
"models/category"
require
"models/categorization"
require
"models/edge"
class
RelationTest
<
ActiveRecord
::
TestCase
fixtures
:authors
,
:author_addresses
,
:topics
,
:entrants
,
:developers
,
:companies
,
:developers_projects
,
:accounts
,
:categories
,
:categorizations
,
:posts
,
:comments
,
:tags
,
:taggings
,
:cars
,
:minivans
fixtures
:authors
,
:author_addresses
,
:topics
,
:entrants
,
:developers
,
:companies
,
:developers_projects
,
:accounts
,
:categories
,
:categorizations
,
:categories_posts
,
:posts
,
:comments
,
:tags
,
:taggings
,
:cars
,
:minivans
class
TopicWithCallbacks
<
ActiveRecord
::
Base
self
.
table_name
=
:topics
...
...
@@ -1810,6 +1810,10 @@ def test_presence
assert_equal
[
posts
(
:welcome
)],
custom_post_relation
.
ranked_by_comments
.
limit_by
(
1
).
to_a
end
test
"alias_tracker respects a custom table"
do
assert_equal
posts
(
:welcome
),
custom_post_relation
(
"categories_posts"
).
joins
(
:categories
).
first
end
test
"#load"
do
relation
=
Post
.
all
assert_queries
(
1
)
do
...
...
@@ -1930,8 +1934,8 @@ def test_relation_join_method
end
private
def
custom_post_relation
table_alias
=
Post
.
arel_table
.
alias
(
"omg_posts"
)
def
custom_post_relation
(
alias_name
=
"omg_posts"
)
table_alias
=
Post
.
arel_table
.
alias
(
alias_name
)
table_metadata
=
ActiveRecord
::
TableMetadata
.
new
(
Post
,
table_alias
)
predicate_builder
=
ActiveRecord
::
PredicateBuilder
.
new
(
table_metadata
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录