Is there any reason why HABTM default select clause is select * from ... rather than select table_name.* ... ? As it is attributes from the join table ''leak'' into the attributes for the collection you are fetching (which for example makes a mess if you call to_xml on it). On the other hand has many through does do select table_name.* Is there a specific legacy reason why this is so or is it just historical artificat (ie can we just change it to table_name.*) Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This used to be a desired behavior; here''s the note from the 1.1 changelog: ----- * Added HasAndBelongsToManyAssociation#push_with_attributes(object, join_attributes) that can create associations in the join table with additional attributes. This is really useful when you have information that''s only relevant to the join itself, such as a "added_on" column for an association between post and category. The added attributes will automatically be injected into objects retrieved through the association similar to the piggy-back approach: post.categories.push_with_attributes(category, :added_on => Date.today) post.categories.first.added_on # => Date.today NOTE: The categories table doesn''t have a added_on column, it''s the categories_post join table that does! ---- The method has been deprecated and removed for a while now, though. What attributes are "leaking" in your app? And how do you access them otherwise? --Matt Jones On Dec 27, 2008, at 6:49 AM, Frederick Cheung wrote:> > Is there any reason why HABTM default select clause is select * > from ... rather than select table_name.* ... ? > As it is attributes from the join table ''leak'' into the attributes for > the collection you are fetching (which for example makes a mess if you > call to_xml on it). On the other hand has many through does do select > table_name.* > > Is there a specific legacy reason why this is so or is it just > historical artificat (ie can we just change it to table_name.*) >--~--~---------~--~----~------------~-------~--~----~ 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 27 Dec 2008, at 15:10, Matt Jones wrote:> > ---- > The method has been deprecated and removed for a while now, though. >Ah yes, that does make sense.> What attributes are "leaking" in your app? And how do you access them > otherwise? >Not my app :-) if you''ve got foo habtm bars then you get foo_id and bar_id attributes appearing, which you don''t care about or ever want to access. Fred> --Matt Jones > > On Dec 27, 2008, at 6:49 AM, Frederick Cheung wrote: > >> >> Is there any reason why HABTM default select clause is select * >> from ... rather than select table_name.* ... ? >> As it is attributes from the join table ''leak'' into the attributes >> for >> the collection you are fetching (which for example makes a mess if >> you >> call to_xml on it). On the other hand has many through does do select >> table_name.* >> >> Is there a specific legacy reason why this is so or is it just >> historical artificat (ie can we just change it to table_name.*) >> > > --~--~---------~--~----~------------~-------~--~----~ > 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 > -~----------~----~----~----~------~----~------~--~--- >
Frederick Cheung wrote:> > On 27 Dec 2008, at 15:10, Matt Jones wrote: > >> >> ---- >> The method has been deprecated and removed for a while now, though. >> > Ah yes, that does make sense.Yeah, the behaviour has been ''frowned upon'' for a while. Prior to the has_many through functionality it was a ''neat hack'' for things like having created_at on some association. Now it''s kinda disgusting :) Could be worth removing it for 2.3 now as it''s just bound to cause confusion and people can manually do :select if they want it. -- Cheers, Koz --~--~---------~--~----~------------~-------~--~----~ 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 28 Dec 2008, at 17:53, Michael Koziarski wrote:> > Frederick Cheung wrote: >> >> On 27 Dec 2008, at 15:10, Matt Jones wrote: >> >>> >>> ---- >>> The method has been deprecated and removed for a while now, though. >>> >> Ah yes, that does make sense. > > Yeah, the behaviour has been ''frowned upon'' for a while. Prior to the > has_many through functionality it was a ''neat hack'' for things like > having created_at on some association. > > Now it''s kinda disgusting :) > > Could be worth removing it for 2.3 now as it''s just bound to cause > confusion and people can manually do :select if they want it.Makes sense to me. Anyone desperately holding onto this bit of functionality ? Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It''s funny because the functionality is the only thing omitted from the email. -Mike Frederick Cheung wrote:> On 28 Dec 2008, at 17:53, Michael Koziarski wrote: > > >> Frederick Cheung wrote: >> >>> On 27 Dec 2008, at 15:10, Matt Jones wrote: >>> >>> >>>> ---- >>>> The method has been deprecated and removed for a while now, though. >>>> >>>> >>> Ah yes, that does make sense. >>> >> Yeah, the behaviour has been ''frowned upon'' for a while. Prior to the >> has_many through functionality it was a ''neat hack'' for things like >> having created_at on some association. >> >> Now it''s kinda disgusting :) >> >> Could be worth removing it for 2.3 now as it''s just bound to cause >> confusion and people can manually do :select if they want it. >> > > Makes sense to me. Anyone desperately holding onto this bit of > functionality ? > > Fred > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If you don''t know what it is, you probably don''t need it. Basically if you have an additional column in the join table, its value will appear as a magic attribute on the retrieved records. On Mon, Dec 29, 2008 at 9:54 AM, Mike Gaffney <mr.gaffo@gmail.com> wrote:> > It''s funny because the functionality is the only thing omitted from the > email. > > -Mike > > Frederick Cheung wrote: > > On 28 Dec 2008, at 17:53, Michael Koziarski wrote: > > > > Frederick Cheung wrote: > > > On 27 Dec 2008, at 15:10, Matt Jones wrote: > > > > ---- > The method has been deprecated and removed for a while now, though. > > > > Ah yes, that does make sense. > > > Yeah, the behaviour has been ''frowned upon'' for a while. Prior to the > has_many through functionality it was a ''neat hack'' for things like > having created_at on some association. > > Now it''s kinda disgusting :) > > Could be worth removing it for 2.3 now as it''s just bound to cause > confusion and people can manually do :select if they want it. > > > Makes sense to me. Anyone desperately holding onto this bit of > functionality ? > > Fred > > > > > > >-- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---