I have a vanilla habtm association between Article and Category.
Article.all
# => [#<Article id: 1, title: "Rails Conf 2009", created_at:
"2008-11-05 10:28:10", updated_at: "2008-11-05
10:28:10">, #<Article
id: 2, title: "Cached Models", created_at: "2008-11-05
10:28:10",
updated_at: "2008-11-05 10:28:10">]
Now we try to load the same articles via habtm association:
Category.first.articles
# => [#<Article id: 1, title: "Cached Models", created_at:
"2008-11-05
10:28:10", updated_at: "2008-11-05 10:28:10">, #<Article
id: 2, title:
"Rails Conf 2009", created_at: "2008-11-05 10:28:10",
updated_at:
"2008-11-05 10:28:10">]
Look at the article ids in the first and the second case.
Here the query used by habtm:
SELECT * FROM "articles" INNER JOIN "articles_categories" ON
"articles".id = "articles_categories".article_id WHERE
("articles_categories".category_id = 1 )
With sqlite3 It returns: http://gist.github.com/22311
SQLiteAdapter#select exclude all the extra and unknown columns ad
returns a wrong record id for the current row.
This problem also affects MySqlAdapter
I''m figuring how to fix it, in the meanwhile I opened a ticket on LH
(http://tinyurl.com/5aevu9).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On 5 Nov 2008, at 11:14, jodosha wrote:> > > > Look at the article ids in the first and the second case. > > Here the query used by habtm: > SELECT * FROM "articles" INNER JOIN "articles_categories" ON > "articles".id = "articles_categories".article_id WHERE > ("articles_categories".category_id = 1 ) >Your article_categories table shouldn''t have an id column for habtm (you could also change the select to be articles.*) Fred> With sqlite3 It returns: http://gist.github.com/22311 > SQLiteAdapter#select exclude all the extra and unknown columns ad > returns a wrong record id for the current row. > > This problem also affects MySqlAdapter > > I''m figuring how to fix it, in the meanwhile I opened a ticket on LH > (http://tinyurl.com/5aevu9). > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Oh, you''re right. I totally forgot about this. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---