From 8cccb6a3238062e71ac6daadb7c897ec977bba83 Mon Sep 17 00:00:00 2001 From: Elad Meidar Date: Sat, 26 Sep 2009 23:13:39 -0400 Subject: [PATCH] LH2998 - Fix find with hash conditions with symbol keys and include on has many --- activerecord/lib/active_record/associations.rb | 2 +- .../has_many_through_associations_test.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 266a52d..b365797 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1795,7 +1795,7 @@ module ActiveRecord if value.is_a?(Hash) key.to_s else - tables_in_string(key) if key.is_a?(String) + tables_in_string(key.to_s) if key.is_a?(String) || key.is_a?(Symbol) end end tables.flatten.compact diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 5f13b66..f771699 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -16,7 +16,7 @@ require 'models/company' require 'models/developer' class HasManyThroughAssociationsTest < ActiveRecord::TestCase - fixtures :posts, :readers, :people, :comments, :authors, :owners, :pets, :toys, :jobs, :references, :companies + fixtures :posts, :readers, :people, :comments, :authors, :owners, :pets, :toys, :jobs, :references, :companies, :developers def test_associate_existing assert_queries(2) { posts(:thinking);people(:david) } @@ -346,6 +346,11 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_equal post_with_no_comments, posts(:authorless) end + def test_find_on_has_many_through_association_with_include_and_hash_conditions + Contract.create!(:company => companies(:first_firm), :developer => developers(:david)) + assert_equal 1, Company.find(:all, :include => :developers, :conditions => { :'developers.salary' => 80000 }).size + end + def test_has_many_through_has_one_reflection assert_equal [comments(:eager_sti_on_associations_vs_comment)], authors(:david).very_special_comments end -- 1.6.0.2