<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -307,6 +307,7 @@ module ActiveRecord
 
         klasses_and_ids.each do |klass_and_id|
           klass_name, id_map = *klass_and_id
+          next if id_map.empty?
           klass = klass_name.constantize
 
           table_name = klass.quoted_table_name</diff>
      <filename>activerecord/lib/active_record/association_preload.rb</filename>
    </modified>
    <modified>
      <diff>@@ -145,7 +145,7 @@ class EagerAssociationTest &lt; ActiveRecord::TestCase
   def test_finding_with_includes_on_null_belongs_to_association_with_same_include_includes_only_once
     post = posts(:welcome)
     post.update_attributes!(:author =&gt; nil)
-    post = assert_queries(2) { Post.find(post.id, :include =&gt; {:author_with_address =&gt; :author_address}) } # find the post, then find the author which is null so no query for the address
+    post = assert_queries(1) { Post.find(post.id, :include =&gt; {:author_with_address =&gt; :author_address}) } # find the post, then find the author which is null so no query for the author or address
     assert_no_queries do
       assert_equal nil, post.author_with_address
     end
@@ -705,4 +705,5 @@ class EagerAssociationTest &lt; ActiveRecord::TestCase
   def test_order_on_join_table_with_include_and_limit
     assert_equal 5, Developer.find(:all, :include =&gt; 'projects', :order =&gt; 'developers_projects.joined_on DESC', :limit =&gt; 5).size
   end
+
 end</diff>
      <filename>activerecord/test/cases/associations/eager_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>428e77bf0fcee4369cb8d94011141f791b8e2ba9</id>
    </parent>
  </parents>
  <author>
    <name>Frederick Cheung</name>
    <email>frederick.cheung@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/707d0dd3e1e8df7771073670e4257d933d2818f9</url>
  <id>707d0dd3e1e8df7771073670e4257d933d2818f9</id>
  <committed-date>2008-12-18T11:19:35-08:00</committed-date>
  <authored-date>2008-12-17T15:39:09-08:00</authored-date>
  <message>Fix preloading of belongs_to with null foreign key generating useless query [#1027 state:resolved]</message>
  <tree>97ac33fde3f7e4004d607911ad1b9a5437ddf037</tree>
  <committer>
    <name>Pratik Naik</name>
    <email>pratiknaik@gmail.com</email>
  </committer>
</commit>
