diff options
author | Lucia Escanellas <raviolicode@gmail.com> | 2011-06-23 22:32:22 -0300 |
---|---|---|
committer | Lucia Escanellas <raviolicode@gmail.com> | 2011-06-24 13:37:08 -0300 |
commit | 9734a416faaa8149fa5914b0afe2e6761ad5ec20 (patch) | |
tree | 1f4873033932715031f163b42b5ebd49b347d23d /activerecord/lib | |
parent | 8a1319dec09672cbb1a4d6fce1db09f10c44bceb (diff) | |
download | rails-9734a416faaa8149fa5914b0afe2e6761ad5ec20.tar.gz rails-9734a416faaa8149fa5914b0afe2e6761ad5ec20.tar.bz2 rails-9734a416faaa8149fa5914b0afe2e6761ad5ec20.zip |
Improve ordering of multiple columns on postgresql
* Only on postgresql, order("first asc, second asc") was invalid
* Closes #1720
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 6d638628df..29dd0a9ea3 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -940,7 +940,7 @@ module ActiveRecord # Construct a clean list of column names from the ORDER BY clause, removing # any ASC/DESC modifiers - order_columns = orders.collect { |s| s =~ /^(.+)\s+(ASC|DESC)\s*$/i ? $1 : s } + order_columns = orders.collect { |s| s.gsub(/\s+(ASC|DESC)\s*/i, '') } order_columns.delete_if { |c| c.blank? } order_columns = order_columns.zip((0...order_columns.size).to_a).map { |s,i| "#{s} AS alias_#{i}" } |