1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

yay, more oracle hacks

This commit is contained in:
Aaron Patterson 2010-09-24 15:09:26 -07:00
parent 6420041b88
commit 245d797a8c
2 changed files with 14 additions and 2 deletions

View file

@ -54,11 +54,11 @@ module Arel
/DISTINCT.*FIRST_VALUE/ === projection
end
end
orders = o.orders
orders = o.orders.map { |x| visit x }.join(', ').split(',')
o.orders = []
orders.each_with_index do |order, i|
o.orders <<
Nodes::SqlLiteral.new("alias_#{i}__ #{'DESC' if /\bdesc$/i === order}")
Nodes::SqlLiteral.new("alias_#{i}__#{' DESC' if /\bdesc$/i === order}")
end
o
end

View file

@ -31,6 +31,18 @@ module Arel
check sql.should == sql2
end
it 'splits orders with commas' do
# *sigh*
select = "DISTINCT foo.id, FIRST_VALUE(projects.name) OVER (foo) AS alias_0__"
stmt = Nodes::SelectStatement.new
stmt.cores.first.projections << Nodes::SqlLiteral.new(select)
stmt.orders << Nodes::SqlLiteral.new('foo, bar')
sql = @visitor.accept(stmt)
sql.should be_like %{
SELECT #{select} ORDER BY alias_0__, alias_1__
}
end
describe 'Nodes::SelectStatement' do
describe 'limit' do
it 'adds a rownum clause' do