From 648797986725404d491ce82288cd8cd2193c0d3d Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 18 Nov 2008 14:05:03 -0600 Subject: [PATCH] FIX 1404: Added case for Hash to conditions_tables. --- activerecord/lib/active_record/associations.rb | 1 + activerecord/test/cases/associations/eager_test.rb | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 7f78191..1701350 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1731,6 +1731,7 @@ module ActiveRecord case cond when nil then all when Array then all << cond.first + when Hash then all << cond.keys else all << cond end end diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 5f43975..329bec6 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -385,12 +385,24 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_equal count, posts.size end - def test_eager_with_has_many_and_limit_ond_high_offset + def test_eager_with_has_many_and_limit_and_high_offset posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ]) assert_equal 0, posts.size end - def test_count_eager_with_has_many_and_limit_ond_high_offset + def test_eager_with_has_many_and_limit_and_high_offset_and_multiple_array_conditions + posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, + :conditions => [ "authors.name = ? and comments.body = ?", 'David', 'go crazy' ]) + assert_equal 0, posts.size + end + + def test_eager_with_has_many_and_limit_and_high_offset_and_multiple_hash_conditions + posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, + :conditions => { 'authors.name' => 'David', 'comments.body' => 'go crazy' }) + assert_equal 0, posts.size + end + + def test_count_eager_with_has_many_and_limit_and_high_offset posts = Post.count(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ]) assert_equal 0, posts end -- 1.5.4.5 From f0a8790adfe7252b466d1b13731c2f93d5ef6e93 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 18 Nov 2008 14:07:27 -0600 Subject: [PATCH] Removed trailing whitespace. --- activerecord/test/cases/associations/eager_test.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 329bec6..b0662c3 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -401,7 +401,7 @@ class EagerAssociationTest < ActiveRecord::TestCase :conditions => { 'authors.name' => 'David', 'comments.body' => 'go crazy' }) assert_equal 0, posts.size end - + def test_count_eager_with_has_many_and_limit_and_high_offset posts = Post.count(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ]) assert_equal 0, posts -- 1.5.4.5