Hi list, I get the error "Not unique table/alias" (myql 4.1) when trying eager load 2 classes that use the same base class (not STI) Example: <code> class Wedding < ActiveRecord::Base belongs_to :bride, :class_name => ''Person'', :foreign_key => ''bride_id'' belongs_to :groom, :class_name => ''Person'', :foreign_key => ''groom_id'' end </code> Trying to eager load the bride and groom classes blows up because the "people" table is left outer joined twice: <code> Wedding.find(:first, :include => [:bride, :groom]) </code> Is there a way to specify an alias for the table name? (like ''LEFT OUTER JOIN people AS p1'') Any suggestions? Thanks, EJC
Pete Yandell
2006-Feb-12 22:57 UTC
[Rails] Error when Eager Loading "Not unique table/alias"
This is a known issue with Rails. Check out: http://wiki.rubyonrails.org/rails/pages/Allow+Multiple+Associations +Same+Table+Plugin That fixes that problem and a couple of others, at the expense of a) throwing an error in one plugin test and b) not working with edge rails. Cheers, Pete Yandell
Is this something that''ll be address in later versions of Rails, like 1.1? I couldn''t quite tell from the tickets. On 2/12/06, Pete Yandell <pete@notahat.com> wrote:> This is a known issue with Rails. Check out: > > http://wiki.rubyonrails.org/rails/pages/Allow+Multiple+Associations > +Same+Table+Plugin > > That fixes that problem and a couple of others, at the expense of a) > throwing an error in one plugin test and b) not working with edge rails. > > Cheers, > > Pete Yandell > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Jeremy Evans
2006-Feb-13 06:26 UTC
[Rails] Error when Eager Loading "Not unique table/alias"
On 2/12/06, Ed C. <defeated2k4@gmail.com> wrote:> Is this something that''ll be address in later versions of Rails, like > 1.1? I couldn''t quite tell from the tickets.I''ll probably update the plugin when Rails 1.1 comes out. I don''t have time to track Edge Rails and update the plugin every time it breaks. I feel that this functionality really should be in core, but it doesn''t seem to be a priority for the core team. I''d happily make any changes to the patch/plugin to get it accepted into core, but nobody from the core team has contacted me about it and I''m not willing to fight an uphill battle when the plugin/patch method is the path of least resistance.