The AR documentation states: You can use eager loading on multiple associations from the same table, but you cannot use those associations in orders and conditions as there is currently not any way to disambiguate them. Has anyone worked up a patch for this? I''m thinking that it would be useful to state, for instance: has_many :deployments, :class_name => ''Deployment'', :order => "_table_.start_at" Then, AR would automatically swap out the "_table_" string for the created-on-the-fly table alias. This would allow you, for instance, to refer to the same table multiple times with conditions and order clauses. Has anyone thought of another solution to this problem? Would this be a feasible way to address the problem? I''d be willing to work on a patch if necessary. Thanks, Norman Elton --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Sounds good. If there''s anything I can do, feel free to put me in touch with whoever''s in charge. Norman On May 2, 10:25 am, Michael Koziarski <mich...@koziarski.com> wrote:> There''s some work under way for the next release of rails ( post 2.1 ) > to completely rejig all the query generation for precisely these kind > of issues. > > I think it''ll probably be easier to hold fire till then. > > Cheers > > Koz > > On 2/05/2008, at 4:21 AM, Norm <normel...@gmail.com> wrote: > > > > > The AR documentation states: > > > You can use eager loading on multiple associations from the same > > table, but you cannot use those associations in orders and conditions > > as there is currently not any way to disambiguate them. > > > Has anyone worked up a patch for this? I''m thinking that it would be > > useful to state, for instance: > > > has_many :deployments, :class_name => ''Deployment'', :order => > > "_table_.start_at" > > > Then, AR would automatically swap out the "_table_" string for the > > created-on-the-fly table alias. This would allow you, for instance, to > > refer to the same table multiple times with conditions and order > > clauses. > > > Has anyone thought of another solution to this problem? Would this be > > a feasible way to address the problem? I''d be willing to work on a > > patch if necessary. > > > Thanks, > > > Norman Elton--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-02 10:13 UTC
Re: Patch needed for AR multiple associations on same table?
On 2 May 2008, at 04:29, Norm wrote:> > Sounds good. If there''s anything I can do, feel free to put me in > touch with whoever''s in charge. >It''s also worth noting that independantly eager loading has changed in 2.1 (though the old mechanism is still there). I vaguely remember that if it''s a conditions thing then you can do something like :conditions => ''#{"#{aliased_table_name}." rescue ""}foo = 123'' Fred> Norman > > On May 2, 10:25 am, Michael Koziarski <mich...@koziarski.com> wrote: >> There''s some work under way for the next release of rails ( post >> 2.1 ) >> to completely rejig all the query generation for precisely these kind >> of issues. >> >> I think it''ll probably be easier to hold fire till then. >> >> Cheers >> >> Koz >> >> On 2/05/2008, at 4:21 AM, Norm <normel...@gmail.com> wrote: >> >> >> >>> The AR documentation states: >> >>> You can use eager loading on multiple associations from the same >>> table, but you cannot use those associations in orders and >>> conditions >>> as there is currently not any way to disambiguate them. >> >>> Has anyone worked up a patch for this? I''m thinking that it would be >>> useful to state, for instance: >> >>> has_many :deployments, :class_name => ''Deployment'', :order => >>> "_table_.start_at" >> >>> Then, AR would automatically swap out the "_table_" string for the >>> created-on-the-fly table alias. This would allow you, for >>> instance, to >>> refer to the same table multiple times with conditions and order >>> clauses. >> >>> Has anyone thought of another solution to this problem? Would this >>> be >>> a feasible way to address the problem? I''d be willing to work on a >>> patch if necessary. >> >>> Thanks, >> >>> Norman Elton > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> It''s also worth noting that independantly eager loading has changed in > 2.1 (though the old mechanism is still there). > I vaguely remember that if it''s a conditions thing then you can do > something like :conditions => ''#{"#{aliased_table_name}." rescue > ""}foo = 123''Fred, Thanks for your note. Doing a little research, I found the webpage that you referenced a few days ago (didn''t see it before, sorry). I''ll trying moving to edge and see how things work there. Norman --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2008-May-02 14:25 UTC
Re: Patch needed for AR multiple associations on same table?
There''s some work under way for the next release of rails ( post 2.1 ) to completely rejig all the query generation for precisely these kind of issues. I think it''ll probably be easier to hold fire till then. Cheers Koz On 2/05/2008, at 4:21 AM, Norm <normelton@gmail.com> wrote:> > The AR documentation states: > > You can use eager loading on multiple associations from the same > table, but you cannot use those associations in orders and conditions > as there is currently not any way to disambiguate them. > > Has anyone worked up a patch for this? I''m thinking that it would be > useful to state, for instance: > > has_many :deployments, :class_name => ''Deployment'', :order => > "_table_.start_at" > > Then, AR would automatically swap out the "_table_" string for the > created-on-the-fly table alias. This would allow you, for instance, to > refer to the same table multiple times with conditions and order > clauses. > > Has anyone thought of another solution to this problem? Would this be > a feasible way to address the problem? I''d be willing to work on a > patch if necessary. > > Thanks, > > Norman Elton > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---