Hey, Currently the value of :order key in find method of ActiveRecord has to be a string, :order => '' name asc, created_at desc '' Wouldn''t It more be more inuitive to say something like :order => { :name => :asc, :created_at => :desc} Similar to :conditions, which has got Hash support recently. Thoughts? Jatinder --~--~---------~--~----~------------~-------~--~----~ 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 8/22/07, Jatinder Singh <jatinder.saundh@gmail.com> wrote:> Wouldn''t It more be more inuitive to say something like > :order => { :name => :asc, :created_at => :desc}Intuitively this is a nice idea, but it will cause problems because the order of columns in an ORDER BY clause is significant, and yet there''s no explicit ordering within a hash. In other words, given :order => { :name => :asc, :created_at => :desc} there''s no way to know whether ORDER BY name ASC, created_at DESC or ORDER BY created_at DESC, name ASC is intended... -- * J * ~ --~--~---------~--~----~------------~-------~--~----~ 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 8/22/07, James Adam <james.adam@gmail.com> wrote:> > > On 8/22/07, Jatinder Singh <jatinder.saundh@gmail.com> wrote: > > Wouldn''t It more be more inuitive to say something like > > :order => { :name => :asc, :created_at => :desc} > > Intuitively this is a nice idea, but it will cause problems because > the order of columns in an ORDER BY clause is significant, and yet > there''s no explicit ordering within a hash.James is right. Also, conditions can be represented as a bunch of key-value pairs, but that doesn''t fit well for order clauses. --~--~---------~--~----~------------~-------~--~----~ 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 yes, ordering is a problem with this approach. String works well unless we want to have ordered hash here. -Jatinder On 8/22/07, Mislav Marohnić <mislav.marohnic@gmail.com> wrote:> On 8/22/07, James Adam <james.adam@gmail.com> wrote: > > > > On 8/22/07, Jatinder Singh <jatinder.saundh@gmail.com> wrote: > > > Wouldn't It more be more inuitive to say something like > > > :order => { :name => :asc, :created_at => :desc} > > > > Intuitively this is a nice idea, but it will cause problems because > > the order of columns in an ORDER BY clause is significant, and yet > > there's no explicit ordering within a hash. > > James is right. Also, conditions can be represented as a bunch of key-value > pairs, but that doesn't fit well for order clauses. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ActiveSupport::OrderedHash won't work here. On 8/22/07, Jatinder Singh <jatinder.saundh@gmail.com> wrote:> Oh yes, ordering is a problem with this approach. String works well > unless we want to have ordered hash here. > > > > -Jatinder > > On 8/22/07, Mislav Marohnić <mislav.marohnic@gmail.com> wrote: > > On 8/22/07, James Adam <james.adam@gmail.com> wrote: > > > > > > On 8/22/07, Jatinder Singh <jatinder.saundh@gmail.com> wrote: > > > > Wouldn't It more be more inuitive to say something like > > > > :order => { :name => :asc, :created_at => :desc} > > > > > > Intuitively this is a nice idea, but it will cause problems because > > > the order of columns in an ORDER BY clause is significant, and yet > > > there's no explicit ordering within a hash. > > > > James is right. Also, conditions can be represented as a bunch of key-value > > pairs, but that doesn't fit well for order clauses. > > > > > > > > > > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---