From 680bac202da2e9c717d4e47c9402f291a8971fad Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 8 Apr 2014 20:38:00 -0700 Subject: move the ORDER BY to the RowNumber method --- lib/arel/visitors/mssql.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/arel') 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 -- cgit v1.2.3