Hi, Is there any particular reason why AR does not support composite primary keys? This looks like a pretty nice feature to add. Regards, Luís Ferreira -- 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 Friday, 15 June 2012 at 4:54 AM, Luís Ferreira wrote:> Hi, > > Is there any particular reason why AR does not support composite primary keys? This looks like a pretty nice feature to add. >Because outside of people with ''legacy schemas'' there''s not really a large number of compelling use cases that justify the additional complexity. It''s not just a matter of making find take two arguments, you also have to bake that support into all the associations etc. On the whole, no one has felt particularly compelled to do the large amount of work when you can work around the limitation by just using a standard primary key with a unique index for your composite values. -- 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.
You are right, I can probably achieve my goals with a unique index and a validates_uniqueness_of with :scope. Thanks for the tip On Jun 14, 2012, at 10:05 PM, Michael Koziarski wrote:> On Friday, 15 June 2012 at 4:54 AM, Luís Ferreira wrote: >> Hi, >> >> Is there any particular reason why AR does not support composite primary keys? This looks like a pretty nice feature to add. >> > Because outside of people with ''legacy schemas'' there''s not really a large number of compelling use cases that justify the additional complexity. It''s not just a matter of making find take two arguments, you also have to bake that support into all the associations etc. > > On the whole, no one has felt particularly compelled to do the large amount of work when you can work around the limitation by just using a standard primary key with a unique index for your composite values. > > > -- > 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.Cumprimentos, Luís Ferreira -- 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 14 Jun., 23:05, Michael Koziarski <mich...@koziarski.com> wrote:> On Friday, 15 June 2012 at 4:54 AM, Luís Ferreira wrote: > > Hi, > > > Is there any particular reason why AR does not support composite primary keys? This looks like a pretty nice feature to add. > > Because outside of people with ''legacy schemas'' there''s not really a large number of compelling use cases that justify the additional complexity. It''s not just a matter of making find take two arguments, you also have to bake that support into all the associations etc. > > On the whole, no one has felt particularly compelled to do the large amount of work when you can work around the limitation by just using a standard primary key with a unique index for your composite values.Dr. Nic did it: https://github.com/drnic/composite_primary_keys -- 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.