Permalink
Browse files

Fixed usage of :limit and with_scope when the association in scope is…

… a 1:m (closes #5208) [alex@purefiction.net]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4422 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed Jun 3, 2006
1 parent 2fbcae1 commit d016d9a6d4d6f998bc4feb2c63908bb75a1529e3
Showing with 11 additions and 1 deletion.
  1. +2 −0 activerecord/CHANGELOG
  2. +1 −1 activerecord/lib/active_record/associations.rb
  3. +8 −0 activerecord/test/base_test.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net]
+
* Fixed migration trouble with SQLite when NOT NULL is used in the new definition #5215 [greg@lapcominc.com]
* Fixed problems with eager loading and counting on SQL Server #5212 [kajism@yahoo.com]
@@ -1145,7 +1145,7 @@ def construct_finder_sql_with_included_associations(options, join_dependency)
add_joins!(sql, options, scope)
add_conditions!(sql, options[:conditions], scope)
- add_limited_ids_condition!(sql, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && options[:limit]
+ add_limited_ids_condition!(sql, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit])
sql << "ORDER BY #{options[:order]} " if options[:order]
@@ -1195,6 +1195,14 @@ def test_scoped_find_order
assert scoped_developers.include?(developers(:david))
end
+ def test_scoped_find_limit_offset_including_has_many_association
+ topics = Topic.with_scope(:find => {:limit => 1, :offset => 1, :include => :replies}) do
+ Topic.find(:all, :order => "topics.id")
+ end
+ assert_equal 1, topics.size
+ assert_equal 2, topics.first.id
+ end
+
def test_base_class
assert LoosePerson.abstract_class?
assert !LooseDescendant.abstract_class?

0 comments on commit d016d9a

Please sign in to comment.