diff options
author | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-11-07 09:54:43 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-11-07 09:55:17 -0200 |
commit | 6709078eb1f61a1f8d54fcd82e9a07e96383ec8a (patch) | |
tree | 2767b7ab2a44ace8e11831a805096b2a28c554ae /activerecord/lib | |
parent | 1acc086278c974d7a3cdb0459cd65f73641abe33 (diff) | |
download | rails-6709078eb1f61a1f8d54fcd82e9a07e96383ec8a.tar.gz rails-6709078eb1f61a1f8d54fcd82e9a07e96383ec8a.tar.bz2 rails-6709078eb1f61a1f8d54fcd82e9a07e96383ec8a.zip |
use column names as order by complex function parameters, fix for postgresql adapter to correctly remove ASC/DESC
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
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 e7fb8524ce..ccc5085b84 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -937,7 +937,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.split.first } + order_columns = orders.collect { |s| s =~ /^(.+)\s+(ASC|DESC)\s*$/i ? $1 : s } 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}" } |