Patch needed for AR multiple associations on same table?

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

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

Sounds good. If there's anything I can do, feel free to put me in touch with whoever's in charge.

Norman

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

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