Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

construct_sql in HasManyThroughAssociation is broken

#2757

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
  case
    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
    else
      @finder_sql = construct_conditions
  end

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?

Reported by Jonas Wagner · June 4th, 2009 @ 01:30 PM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • 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.

    October 9th, 2010 @ 04:05 AM