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.

ActiveRecord: SELECT clause breaks when INCLUDE added

#975

This issue occurs on 2.1 and trunk:

This works - returns all the fields plus "something":

  find(:all,
       :select => "* , table1.field AS something",
       :joins => "LEFT JOIN table3 ON table3.field = table4.id AND table3.user_id = #{curruser.id}",
       :conditions => ["some clauses"]

This does not return "something" (:include and :order have been added):

  find(:all,
       :select => "* , table1.field AS something",
       :include => [:table2],
       :joins => "LEFT JOIN table3 ON table3.field = table4.id AND table3.user_id = #{curruser.id}",
       :conditions => ["some clauses"]
       :order => "table2.sort_order ASC"

Reported by mtkd · September 5th, 2008 @ 12:58 PM

State: duplicate
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Tarmo Tänav
    Tarmo Tänav
    • State changed from new to duplicate

    There's a newer ticket #1060 Allow :select option with join-based include with a patch that supposedly does implement this (though this has never before worked and there has always been an assumption that it is not going to)

    September 18th, 2008 @ 04:25 AM