test/visitors/test_oracle.rb in arel-2.0.6 vs test/visitors/test_oracle.rb in arel-2.0.7.beta.20110110114925
- old
+ new
@@ -57,47 +57,47 @@
describe 'Nodes::SelectStatement' do
describe 'limit' do
it 'adds a rownum clause' do
stmt = Nodes::SelectStatement.new
- stmt.limit = 10
+ stmt.limit = Nodes::Limit.new(10)
sql = @visitor.accept stmt
sql.must_be_like %{ SELECT WHERE ROWNUM <= 10 }
end
it 'is idempotent' do
stmt = Nodes::SelectStatement.new
stmt.orders << Nodes::SqlLiteral.new('foo')
- stmt.limit = 10
+ stmt.limit = Nodes::Limit.new(10)
sql = @visitor.accept stmt
sql2 = @visitor.accept stmt
sql.must_equal sql2
end
it 'creates a subquery when there is order_by' do
stmt = Nodes::SelectStatement.new
stmt.orders << Nodes::SqlLiteral.new('foo')
- stmt.limit = 10
+ stmt.limit = Nodes::Limit.new(10)
sql = @visitor.accept stmt
sql.must_be_like %{
SELECT * FROM (SELECT ORDER BY foo) WHERE ROWNUM <= 10
}
end
it 'creates a subquery when there is DISTINCT' do
stmt = Nodes::SelectStatement.new
stmt.cores.first.projections << Nodes::SqlLiteral.new('DISTINCT id')
- stmt.limit = 10
+ stmt.limit = Arel::Nodes::Limit.new(10)
sql = @visitor.accept stmt
sql.must_be_like %{
SELECT * FROM (SELECT DISTINCT id) WHERE ROWNUM <= 10
}
end
it 'creates a different subquery when there is an offset' do
stmt = Nodes::SelectStatement.new
- stmt.limit = 10
+ stmt.limit = Nodes::Limit.new(10)
stmt.offset = Nodes::Offset.new(10)
sql = @visitor.accept stmt
sql.must_be_like %{
SELECT * FROM (
SELECT raw_sql_.*, rownum raw_rnum_
@@ -108,10 +108,10 @@
}
end
it 'is idempotent with different subquery' do
stmt = Nodes::SelectStatement.new
- stmt.limit = 10
+ stmt.limit = Nodes::Limit.new(10)
stmt.offset = Nodes::Offset.new(10)
sql = @visitor.accept stmt
sql2 = @visitor.accept stmt
sql.must_equal sql2
end