This project is archived and is in readonly mode.

#412 ✓stale
darren_hoo

Eager loading of has-many association does not respect :finder_sql

Reported by darren_hoo | June 13th, 2008 @ 08:08 PM


class Firm < Company
     has_many :clients_using_finder_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE 1=1'
     has_many :empty_clients_using_finder_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE 1=0'
end

def test_preloading_when_using_finder_sql
    firm = Firm.find(:first,:include => :empty_clients_using_finder_sql)
    assert_equal(0,firm.empty_clients_using_finder_sql.size)
end

a patch against rails git is attached

Comments and changes to this ticket

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages