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
on 2006-02-12 22:59
on 2006-02-13 00:58
This is a known issue with Rails. Check out: http://wiki.rubyonrails.org/rails/pages/Allow+Mult... +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 Y.
on 2006-02-13 03:27
Is this something that'll be address in later versions of Rails, like 1.1? I couldn't quite tell from the tickets.
on 2006-02-13 08:26
On 2/12/06, Ed C. <firstname.lastname@example.org> 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.