diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-04-06 04:16:08 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-04-06 04:16:08 +0000 |
commit | 31d8169e3ecb0a63db3a3bd6130f5d8bbcd0f39a (patch) | |
tree | 455a2d2920857887d66e8dd0fa594a847609e1f3 /activerecord/lib/active_record | |
parent | 42d8548e94395435ccc00b453a4db65aca157726 (diff) | |
download | rails-31d8169e3ecb0a63db3a3bd6130f5d8bbcd0f39a.tar.gz rails-31d8169e3ecb0a63db3a3bd6130f5d8bbcd0f39a.tar.bz2 rails-31d8169e3ecb0a63db3a3bd6130f5d8bbcd0f39a.zip |
Fixed that loading including associations returns all results if Load IDs For Limited Eager Loading returns none (closes #4528) [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4179 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index e97350d902..369983632d 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -962,14 +962,20 @@ module ActiveRecord end def count_with_associations(options = {}) - join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins]) - return count_by_sql(construct_counter_sql_with_included_associations(options, join_dependency)) + catch :invalid_query do + join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins]) + return count_by_sql(construct_counter_sql_with_included_associations(options, join_dependency)) + end + 0 end def find_with_associations(options = {}) - join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins]) - rows = select_all_rows(options, join_dependency) - return join_dependency.instantiate(rows) + catch :invalid_query do + join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins]) + rows = select_all_rows(options, join_dependency) + return join_dependency.instantiate(rows) + end + [] end def configure_dependency_for_has_many(reflection) @@ -1151,6 +1157,8 @@ module ActiveRecord def add_limited_ids_condition!(sql, options, join_dependency) unless (id_list = select_limited_ids_list(options, join_dependency)).empty? sql << "#{condition_word(sql)} #{table_name}.#{primary_key} IN (#{id_list}) " + else + throw :invalid_query end end |