Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
dae16f8c
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 搜索 >>
提交
dae16f8c
编写于
9月 18, 2017
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The name of the key on the associated record is abstracted as `reflection.join_primary_key`
上级
a1aa86b9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
14 addition
and
23 deletion
+14
-23
activerecord/lib/active_record/associations/preloader/association.rb
...d/lib/active_record/associations/preloader/association.rb
+5
-5
activerecord/lib/active_record/associations/preloader/belongs_to.rb
...rd/lib/active_record/associations/preloader/belongs_to.rb
+0
-3
activerecord/lib/active_record/associations/preloader/has_many.rb
...cord/lib/active_record/associations/preloader/has_many.rb
+0
-3
activerecord/lib/active_record/associations/preloader/has_one.rb
...ecord/lib/active_record/associations/preloader/has_one.rb
+0
-3
activerecord/lib/active_record/reflection.rb
activerecord/lib/active_record/reflection.rb
+9
-9
未找到文件。
activerecord/lib/active_record/associations/preloader/association.rb
浏览文件 @
dae16f8c
...
...
@@ -22,16 +22,16 @@ def run(preloader)
end
end
# The name of the key on the associated records
def
association_key_name
raise
NotImplementedError
end
private
def
options
reflection
.
options
end
# The name of the key on the associated records
def
association_key_name
reflection
.
join_primary_key
(
klass
)
end
# The name of the key on the model which declares the association
def
owner_key_name
reflection
.
join_foreign_key
...
...
activerecord/lib/active_record/associations/preloader/belongs_to.rb
浏览文件 @
dae16f8c
...
...
@@ -4,9 +4,6 @@ module ActiveRecord
module
Associations
class
Preloader
class
BelongsTo
<
SingularAssociation
#:nodoc:
def
association_key_name
options
[
:primary_key
]
||
klass
&&
klass
.
primary_key
end
end
end
end
...
...
activerecord/lib/active_record/associations/preloader/has_many.rb
浏览文件 @
dae16f8c
...
...
@@ -4,9 +4,6 @@ module ActiveRecord
module
Associations
class
Preloader
class
HasMany
<
CollectionAssociation
#:nodoc:
def
association_key_name
reflection
.
foreign_key
end
end
end
end
...
...
activerecord/lib/active_record/associations/preloader/has_one.rb
浏览文件 @
dae16f8c
...
...
@@ -4,9 +4,6 @@ module ActiveRecord
module
Associations
class
Preloader
class
HasOne
<
SingularAssociation
#:nodoc:
def
association_key_name
reflection
.
foreign_key
end
end
end
end
...
...
activerecord/lib/active_record/reflection.rb
浏览文件 @
dae16f8c
...
...
@@ -292,13 +292,17 @@ def chain
end
def
get_join_keys
(
association_klass
)
JoinKeys
.
new
(
join_p
k
(
association_klass
),
join_foreign_key
)
JoinKeys
.
new
(
join_p
rimary_key
(
association_klass
),
join_foreign_key
)
end
def
build_scope
(
table
,
predicate_builder
=
predicate_builder
(
table
))
Relation
.
create
(
klass
,
table
,
predicate_builder
)
end
def
join_primary_key
(
_
)
foreign_key
end
def
join_foreign_key
active_record_primary_key
end
...
...
@@ -313,10 +317,6 @@ def predicate_builder(table)
PredicateBuilder
.
new
(
TableMetadata
.
new
(
klass
,
table
))
end
def
join_pk
(
_
)
foreign_key
end
def
primary_key
(
klass
)
klass
.
primary_key
||
raise
(
UnknownPrimaryKey
.
new
(
klass
))
end
...
...
@@ -736,6 +736,10 @@ def association_class
end
end
def
join_primary_key
(
klass
)
polymorphic?
?
association_primary_key
(
klass
)
:
association_primary_key
end
def
join_foreign_key
foreign_key
end
...
...
@@ -745,10 +749,6 @@ def join_foreign_key
def
calculate_constructable
(
macro
,
options
)
!
polymorphic?
end
def
join_pk
(
klass
)
polymorphic?
?
association_primary_key
(
klass
)
:
association_primary_key
end
end
class
HasAndBelongsToManyReflection
<
AssociationReflection
# :nodoc:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录