Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
81246994
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,发现更多精彩内容 >>
提交
81246994
编写于
4月 03, 2013
作者:
N
Neeraj Singh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
has_many through obeys order on through association
fixes #10016
上级
db113d90
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
26 addition
and
3 deletion
+26
-3
activerecord/CHANGELOG.md
activerecord/CHANGELOG.md
+5
-0
activerecord/lib/active_record/associations/association_scope.rb
...ecord/lib/active_record/associations/association_scope.rb
+1
-0
activerecord/test/cases/associations/eager_test.rb
activerecord/test/cases/associations/eager_test.rb
+1
-1
activerecord/test/cases/associations/has_many_through_associations_test.rb
.../cases/associations/has_many_through_associations_test.rb
+7
-1
activerecord/test/fixtures/pets.yml
activerecord/test/fixtures/pets.yml
+5
-0
activerecord/test/fixtures/toys.yml
activerecord/test/fixtures/toys.yml
+6
-0
activerecord/test/models/owner.rb
activerecord/test/models/owner.rb
+1
-1
未找到文件。
activerecord/CHANGELOG.md
浏览文件 @
81246994
## Rails 4.0.0 (unreleased) ##
*
`has_many`
using
`:through`
now obeys the order clause mentioned in
through association. Fixes #10016.
*Neeraj Singh*
*
`belongs_to :touch`
behavior now touches old association when
transitioning to new association.
...
...
activerecord/lib/active_record/associations/association_scope.rb
浏览文件 @
81246994
...
...
@@ -101,6 +101,7 @@ def add_constraints(scope)
scope
.
includes!
item
.
includes_values
scope
.
where_values
+=
item
.
where_values
scope
.
order_values
+=
(
item
.
order_values
-
scope
.
order_values
)
end
end
...
...
activerecord/test/cases/associations/eager_test.rb
浏览文件 @
81246994
...
...
@@ -302,7 +302,7 @@ def test_nested_loading_through_has_one_association_with_conditions_on_nested_as
def
test_eager_association_loading_with_belongs_to_and_foreign_keys
pets
=
Pet
.
all
.
merge!
(
:includes
=>
:owner
).
to_a
assert_equal
3
,
pets
.
length
assert_equal
4
,
pets
.
length
end
def
test_eager_association_loading_with_belongs_to
...
...
activerecord/test/cases/associations/has_many_through_associations_test.rb
浏览文件 @
81246994
...
...
@@ -583,7 +583,7 @@ def test_has_many_association_through_a_belongs_to_association
end
def
test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys
assert_equal
1
,
owners
(
:blackbeard
).
toys
.
count
assert_equal
2
,
owners
(
:blackbeard
).
toys
.
count
end
def
test_find_on_has_many_association_collection_with_include_and_conditions
...
...
@@ -882,6 +882,12 @@ def test_has_many_through_with_polymorphic_source
assert_equal
[
tags
(
:general
)],
post
.
reload
.
tags
end
def
test_has_many_through_obeys_order_on_through_association
owner
=
owners
(
:blackbeard
)
assert
owner
.
toys
.
to_sql
.
include?
(
"pets.name desc"
)
assert_equal
[
"parrot"
,
"bulbul"
],
owner
.
toys
.
map
{
|
r
|
r
.
pet
.
name
}
end
test
"has many through associations on new records use null relations"
do
person
=
Person
.
new
...
...
activerecord/test/fixtures/pets.yml
浏览文件 @
81246994
...
...
@@ -12,3 +12,8 @@ mochi:
pet_id
:
3
name
:
mochi
owner_id
:
2
bulbul
:
pet_id
:
4
name
:
bulbul
owner_id
:
1
activerecord/test/fixtures/toys.yml
浏览文件 @
81246994
...
...
@@ -2,7 +2,13 @@ bone:
toy_id
:
1
name
:
Bone
pet_id
:
1
doll
:
toy_id
:
2
name
:
Doll
pet_id
:
2
bulbuli
:
toy_id
:
3
name
:
Bulbuli
pet_id
:
4
activerecord/test/models/owner.rb
浏览文件 @
81246994
class
Owner
<
ActiveRecord
::
Base
self
.
primary_key
=
:owner_id
has_many
:pets
has_many
:pets
,
->
{
order
'pets.name desc'
}
has_many
:toys
,
:through
=>
:pets
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录