<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 *SVN*
 
+* Ensure hm:t preloading honours reflection options. Resolves #137. [Frederick Cheung]
+
 * Added protection against duplicate migration names (Aslak Helles&#248;y) [#112]
 
 * Base#instantiate_time_object: eliminate check for Time.zone, since we can assume this is set if time_zone_aware_attributes is set to true [Geoff Buesing]</diff>
      <filename>activerecord/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -143,7 +143,8 @@ module ActiveRecord
           through_primary_key = through_reflection.primary_key_name
           unless through_records.empty?
             source = reflection.source_reflection.name
-            through_records.first.class.preload_associations(through_records, source)
+            #add conditions from reflection!
+            through_records.first.class.preload_associations(through_records, source, reflection.options)
             through_records.each do |through_record|
               add_preloaded_records_to_collection(id_to_record_map[through_record[through_primary_key].to_s],
                                                  reflection.name, through_record.send(source))
@@ -251,12 +252,12 @@ module ActiveRecord
         conditions &lt;&lt; append_conditions(options, preload_options)
 
         reflection.klass.find(:all,
-                              :select =&gt; (options[:select] || &quot;#{table_name}.*&quot;),
-                              :include =&gt; options[:include],
+                              :select =&gt; (preload_options[:select] || options[:select] || &quot;#{table_name}.*&quot;),
+                              :include =&gt; preload_options[:include] || options[:include],
                               :conditions =&gt; [conditions, ids],
                               :joins =&gt; options[:joins],
-                              :group =&gt; options[:group],
-                              :order =&gt; options[:order])
+                              :group =&gt; preload_options[:group] || options[:group],
+                              :order =&gt; preload_options[:order] || options[:order])
       end
 
 </diff>
      <filename>activerecord/lib/active_record/association_preload.rb</filename>
    </modified>
    <modified>
      <diff>@@ -275,6 +275,17 @@ class EagerAssociationTest &lt; ActiveRecord::TestCase
                  Author.find(:first, :order =&gt; 'authors.id').hello_post_comments.sort_by(&amp;:id)
   end
 
+  def test_eager_with_has_many_through_join_model_with_conditions_on_top_level
+    assert_equal comments(:more_greetings), Author.find(authors(:david).id, :include =&gt; :comments_with_order_and_conditions).comments_with_order_and_conditions.first
+  end
+
+  def test_eager_with_has_many_through_join_model_with_include
+    author_comments = Author.find(authors(:david).id, :include =&gt; :comments_with_include).comments_with_include.to_a
+    assert_no_queries do
+      author_comments.first.post.title
+    end
+  end
+
   def test_eager_with_has_many_and_limit
     posts = Post.find(:all, :order =&gt; 'posts.id asc', :include =&gt; [ :author, :comments ], :limit =&gt; 2)
     assert_equal 2, posts.size</diff>
      <filename>activerecord/test/cases/associations/eager_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,6 +17,10 @@ class Author &lt; ActiveRecord::Base
   end
   has_many :comments, :through =&gt; :posts
   has_many :comments_containing_the_letter_e, :through =&gt; :posts, :source =&gt; :comments
+  has_many :comments_with_order_and_conditions, :through =&gt; :posts, :source =&gt; :comments, :order =&gt; 'comments.body', :conditions =&gt; &quot;comments.body like 'Thank%'&quot;
+  has_many :comments_with_include, :through =&gt; :posts, :source =&gt; :comments, :include =&gt; :post
+
+
   has_many :comments_desc, :through =&gt; :posts, :source =&gt; :comments, :order =&gt; 'comments.id DESC'
   has_many :limited_comments, :through =&gt; :posts, :source =&gt; :comments, :limit =&gt; 1
   has_many :funky_comments, :through =&gt; :posts, :source =&gt; :comments</diff>
      <filename>activerecord/test/models/author.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8f2f88f128104355b100487008800aeb369ca425</id>
    </parent>
  </parents>
  <author>
    <name>Frederick Cheung</name>
    <email>frederick.cheung@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/3f0dccbbc7c98938349650033ff9a41a814d300d</url>
  <id>3f0dccbbc7c98938349650033ff9a41a814d300d</id>
  <committed-date>2008-05-11T12:01:14-07:00</committed-date>
  <authored-date>2008-05-07T13:35:41-07:00</authored-date>
  <message>Ensure hm:t preloading honours reflection options. [#137 state:resolved]

Signed-off-by: Pratik Naik &lt;pratiknaik@gmail.com&gt;</message>
  <tree>c19906d9c79d3023c7769103584dd8572c5e5870</tree>
  <committer>
    <name>Pratik Naik</name>
    <email>pratiknaik@gmail.com</email>
  </committer>
</commit>
