"Not unique table/alias" errors when upgrading to Rails 2.1

Hi

I've just attempted an upgrade from Rails 2.02 to 2.1 and I'm seeing
dozens of unit test failures with errors like this:

ActionView::TemplateError: Mysql::Error: Not unique table/alias:
'clients': SELECT count(DISTINCT `projects`.id) AS count_all FROM
`projects` LEFT OUTER JOIN `clients` ON `clients`.id =
`projects`.client_id INNER JOIN clients ON projects.client_id =
clients.id WHERE ((`clients`.company_id = 1) AND
((projects.status = 'Active')))

This is invalid SQL which Rails has generated -- it seems to be the
'INNER JOIN clients ON projects.client_id = clients.id' which is
causing the problem, but I can't figure out why this is happening.

Has anyone else experienced a similar problem with Rails 2.1, or can
anyone suggest what new features of 2.1 might be responsible for
introducing these errors?

Many thanks
Olly

Hi

I've just attempted an upgrade from Rails 2.02 to 2.1 and I'm seeing
dozens of unit test failures with errors like this:

What's the code that produces that error?

Fred

I believe it's this declaration:

has_many :active_projects,
    :through => :clients,
    :source => :projects,
    :conditions => "projects.status = 'Active'",
    :order => "ends_on DESC",
    :include => :client