Olly Lylo
2008-Jun-03 07:44 UTC
"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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-03 08:12 UTC
Re: "Not unique table/alias" errors when upgrading to Rails 2.1
On Jun 3, 8:44 am, Olly Lylo <ohea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Olly Lylo
2008-Jun-03 08:33 UTC
Re: "Not unique table/alias" errors when upgrading to Rails 2.1
On Jun 3, 9:12 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What''s the code that produces that error?I believe it''s this declaration: has_many :active_projects, :through => :clients, :source => :projects, :conditions => "projects.status = ''Active''", :order => "ends_on DESC", :include => :client --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---