ARel table aliases

Hi all

I'm battling a little with Rails 3 - trying to get Thinking Sphinx working with it. What I need is some way to interrogate ARel joins to find out table aliases, given a certain association hierarchy.

For example - a forum has a creator (User model), and many topics. Each topic has a creator as well. So, this is a valid query:

  Forum.joins(:creator).joins(:topics => :creator)

The resulting SQL has two references to the users table - how can I interrogate the relation object to find out the users table alias for the :topics => :creator association path?

A far more detailed analysis of what I want can be found as a gist: gist:441625 · GitHub

Any suggestions very much welcome.

Cheers