This project is archived and is in readonly mode.

#2757 ✓stale
Jonas Wagner

construct_sql in HasManyThroughAssociation is broken

Reported by Jonas Wagner | June 4th, 2009 @ 01:30 PM | in 3.x

This is not, strictly spoken, a bug report as I don't know whether it creates any misbehavior... just a piece of code which certainly doesn't work as intended:

Line 183 and following of active_record/associations/has_many_through_association.rb:

def construct_sql
    when @reflection.options[:finder_sql]
      @finder_sql = interpolate_sql(@reflection.options[:finder_sql])

      @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
      @finder_sql << " AND (#{conditions})" if conditions
      @finder_sql = construct_conditions

The case statement does not have a value to test.

@finder_sql is assigned twice, the first value gets overwritten, thus @reflection.options[:finder_sql] has no effect.

Any comments? Somebody with more in-depth knowledge of ActiveRecord motivated to have a look at it?

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Rohit Arondekar

    Rohit Arondekar October 9th, 2010 @ 04:05 AM

    • State changed from “new” to “stale”
    • Importance changed from “” to “”

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>