diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-23 13:37:03 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-23 13:38:56 -0700 |
commit | 66fc8add90445289f4926a914b0eea0c1989450f (patch) | |
tree | 2fc756b7403fa5ca8c285b2dce73803a81fbe29b /lib/arel | |
parent | 9e9e5906754abfb168faba7d265719b5e613624f (diff) | |
download | rails-66fc8add90445289f4926a914b0eea0c1989450f.tar.gz rails-66fc8add90445289f4926a914b0eea0c1989450f.tar.bz2 rails-66fc8add90445289f4926a914b0eea0c1989450f.zip |
writing code that makes me sad
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/visitors/postgresql.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb index 5f0b23a11e..e8aa9b8cb3 100644 --- a/lib/arel/visitors/postgresql.rb +++ b/lib/arel/visitors/postgresql.rb @@ -12,7 +12,7 @@ module Arel sql = super(subquery) [ "SELECT * FROM (#{sql}) AS id_list", - "ORDER BY #{o.orders.map { |x| visit x }.join(', ')}", + "ORDER BY #{aliased_orders(o.orders).join(', ')}", ("LIMIT #{o.limit}" if o.limit), (visit(o.offset) if o.offset), ].compact.join ' ' @@ -28,6 +28,11 @@ module Arel end end end + + def aliased_orders orders + #orders = o.orders.map { |x| visit x }.join(', ').split(',') + (0...orders.size).map { |i| "id_list.alias_#{i}" } + end end end end |