diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-08 20:38:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-08 20:38:00 -0700 |
commit | 680bac202da2e9c717d4e47c9402f291a8971fad (patch) | |
tree | b911a864401cd534a8287a7f7943583c684fb025 /lib/arel/visitors | |
parent | 3cbafe833b5c388403cd78c3bcb278850733d032 (diff) | |
download | rails-680bac202da2e9c717d4e47c9402f291a8971fad.tar.gz rails-680bac202da2e9c717d4e47c9402f291a8971fad.tar.bz2 rails-680bac202da2e9c717d4e47c9402f291a8971fad.zip |
move the ORDER BY to the RowNumber method
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/mssql.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/arel/visitors/mssql.rb b/lib/arel/visitors/mssql.rb index 479a867e37..c7ac56b43e 100644 --- a/lib/arel/visitors/mssql.rb +++ b/lib/arel/visitors/mssql.rb @@ -19,7 +19,7 @@ module Arel end def visit_Arel_Visitors_MSSQL_RowNumber o - "ROW_NUMBER() OVER (#{o.expr}) as _row_num" + "ROW_NUMBER() OVER (ORDER BY #{o.expr}) as _row_num" end def visit_Arel_Nodes_SelectStatement o @@ -58,12 +58,12 @@ module Arel def determine_order_by orders, x if orders.any? - "ORDER BY #{orders.map { |x| visit x }.join(', ')}" + "#{orders.map { |x| visit x }.join(', ')}" else if x.groups.any? - "ORDER BY #{x.groups.map { |g| visit g }.join ', ' }" + "#{x.groups.map { |g| visit g }.join ', ' }" else - "ORDER BY #{find_left_table_pk(x.froms)}" + "#{find_left_table_pk(x.froms)}" end end end |