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:
parent
6420041b88
commit
245d797a8c
2 changed files with 14 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue