Hash for order key in ActiveRecord::find

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

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...

James is right. Also, conditions can be represented as a bunch of key-value pairs, but that doesn’t fit well for order clauses.

Oh yes, ordering is a problem with this approach. String works well unless we want to have ordered hash here.

-Jatinder

ActiveSupport::OrderedHash won't work here.