aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-08 20:38:00 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-08 20:38:00 -0700
commit680bac202da2e9c717d4e47c9402f291a8971fad (patch)
treeb911a864401cd534a8287a7f7943583c684fb025 /lib
parent3cbafe833b5c388403cd78c3bcb278850733d032 (diff)
downloadrails-680bac202da2e9c717d4e47c9402f291a8971fad.tar.gz
rails-680bac202da2e9c717d4e47c9402f291a8971fad.tar.bz2
rails-680bac202da2e9c717d4e47c9402f291a8971fad.zip
move the ORDER BY to the RowNumber method
Diffstat (limited to 'lib')
-rw-r--r--lib/arel/visitors/mssql.rb8
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