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?