<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -131,10 +131,6 @@ module ActiveRecord
           records.map { |record| record.quoted_id }.join(',')
         end
 
-        def interpolate_sql_options!(options, *keys)
-          keys.each { |key| options[key] &amp;&amp;= interpolate_sql(options[key]) }
-        end
-
         def interpolate_sql(sql, record = nil)
           @owner.send(:interpolate_sql, sql, record)
         end</diff>
      <filename>activerecord/lib/active_record/associations/association_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -70,10 +70,8 @@ module ActiveRecord
         end
 
         def construct_sql
-          interpolate_sql_options!(@reflection.options, :finder_sql)
-
           if @reflection.options[:finder_sql]
-            @finder_sql = @reflection.options[:finder_sql]
+            @finder_sql = interpolate_sql(@reflection.options[:finder_sql])
           else
             @finder_sql = &quot;#{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.primary_key_name} = #{owner_quoted_id} &quot;
             @finder_sql &lt;&lt; &quot; AND (#{conditions})&quot; if conditions</diff>
      <filename>activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb</filename>
    </modified>
    <modified>
      <diff>@@ -450,6 +450,13 @@ class HasAndBelongsToManyAssociationsTest &lt; ActiveRecord::TestCase
     assert_equal developers(:david), active_record.developers_with_finder_sql.find(developers(:david).id), &quot;Ruby find&quot;
   end
 
+  def test_find_in_association_with_custom_finder_sql_and_multiple_interpolations
+    # interpolate once:
+    assert_equal [developers(:david), developers(:poor_jamis), developers(:jamis)], projects(:active_record).developers_with_finder_sql, &quot;first interpolation&quot;
+    # interpolate again, for a different project id
+    assert_equal [developers(:david)], projects(:action_controller).developers_with_finder_sql, &quot;second interpolation&quot;
+  end
+
   def test_find_in_association_with_custom_finder_sql_and_string_id
     assert_equal developers(:david), projects(:active_record).developers_with_finder_sql.find(developers(:david).id.to_s), &quot;SQL find&quot;
   end</diff>
      <filename>activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2b69a636c431d62a85b2896d87b69cb13e2b8af0</id>
    </parent>
  </parents>
  <author>
    <name>Nathan Witmer</name>
    <email>nwitmer@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/8cfdcdb35db6e2f6fd5a72a38f4352beab148af1</url>
  <id>8cfdcdb35db6e2f6fd5a72a38f4352beab148af1</id>
  <committed-date>2008-08-16T14:23:48-07:00</committed-date>
  <authored-date>2008-08-16T12:38:01-07:00</authored-date>
  <message>Updated has_and_belongs_to_many association to fix :finder_sql interpolation. [#848 state:resolved]

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