Is it a known issue that associations defined using :through won''t work
with eager loading?
Ie., you can''t do
class Post
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings
end
posts.tags.find(:all, :include => :cantthinkofagoodexample)
I''m digging into this (appears to be a problem with
#construct_finder_sql_with_included_associations), but figured I''d ask
first if anyone''s aware of the problem.
David Heinemeier Hansson
2006-Jan-24 23:49 UTC
Re: has_many :through doesn''t work w/ :include
> Is it a known issue that associations defined using :through won''t work > with eager loading?Yes. Please do work on extending it to be possible, though. At the very least, though, we should bork with an arguments invalid error if you supply both keys unless we get this implemented. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework
David Heinemeier Hansson wrote:>> Is it a known issue that associations defined using :through won''t work >> with eager loading? > > Yes. Please do work on extending it to be possible, though. At the > very least, though, we should bork with an arguments invalid error if > you supply both keys unless we get this implemented.Patch submitted, needs to be tested in other dbs (passes for Oracle)... http://dev.rubyonrails.org/ticket/3611
On 1/25/06, Michael Schoen <schoenm@earthlink.net> wrote:> David Heinemeier Hansson wrote: > >> Is it a known issue that associations defined using :through won''t work > >> with eager loading? > > > > Yes. Please do work on extending it to be possible, though. At the > > very least, though, we should bork with an arguments invalid error if > > you supply both keys unless we get this implemented. > > Patch submitted, needs to be tested in other dbs (passes for Oracle)... > > http://dev.rubyonrails.org/ticket/3611Tests pass for me using PostgreSQL-pr on Win32: E:\Projects\rails_trunk\activerecord>ruby -Ilib;test;test/connections/native_pos tgresql .\test\associations_go_eager_test.rb Using native PostgreSQL Loaded suite ./test/associations_go_eager_test Started ................................... Finished in 1.391 seconds. 35 tests, 79 assertions, 0 failures, 0 errors I still can''t run the full ActiveRecord suite on Win32 without a number of errors, but that''s been going on for a while, and didn''t change with your patch.