Skip to content

Commit

Permalink
Merge [5445] from trunk.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5446 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Nov 7, 2006
1 parent 5f5d8c2 commit 013004b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Find with :include respects scoped :order. #5850

* Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes]

* Deprecation: object transactions warning. [Jeremy Kemper]
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/associations.rb
Expand Up @@ -1169,8 +1169,8 @@ def construct_finder_sql_with_included_associations(options, join_dependency)
add_limited_ids_condition!(sql, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit])

sql << "GROUP BY #{options[:group]} " if options[:group]
sql << "ORDER BY #{options[:order]} " if options[:order]

add_order!(sql, options[:order])
add_limit!(sql, options, scope) if using_limitable_reflections?(join_dependency.reflections)

return sanitize_sql(sql)
Expand Down
10 changes: 10 additions & 0 deletions activerecord/test/base_test.rb
Expand Up @@ -1310,6 +1310,16 @@ def test_scoped_find_limit_offset_including_has_many_association
assert_equal 2, topics.first.id
end

def test_scoped_find_order_including_has_many_association
developers = Developer.with_scope(:find => { :order => 'developers.salary DESC', :include => :projects }) do
Developer.find(:all)
end
assert developers.size >= 2
for i in 1...developers.size
assert developers[i-1].salary >= developers[i].salary
end
end

def test_base_class
assert LoosePerson.abstract_class?
assert !LooseDescendant.abstract_class?
Expand Down

0 comments on commit 013004b

Please sign in to comment.