it'should go over table PK if no .order() or .group()'do
stmt=Nodes::SelectStatement.new
stmt.cores.first.from=@table
stmt.limit=Nodes::Limit.new(10)
sql=@visitor.accept(stmt)
sql.must_be_like"SELECT _t.* FROM (SELECT ROW_NUMBER() OVER (ORDER BY \"users\".\"id\") as _row_num FROM \"users\" ) as _t WHERE _row_num BETWEEN 1 AND 10"
end
it'should go over query ORDER BY if .order()'do
stmt=Nodes::SelectStatement.new
stmt.limit=Nodes::Limit.new(10)
stmt.orders<<Nodes::SqlLiteral.new('order_by')
sql=@visitor.accept(stmt)
sql.must_be_like"SELECT _t.* FROM (SELECT ROW_NUMBER() OVER (ORDER BY order_by) as _row_num) as _t WHERE _row_num BETWEEN 1 AND 10"
end
it'should go over query GROUP BY if no .order() and there is .group()'do
sql.must_be_like"SELECT COUNT(1) as count_id FROM (SELECT _t.* FROM (SELECT ROW_NUMBER() OVER (ORDER BY ) as _row_num) as _t WHERE _row_num BETWEEN 1 AND 10) AS subquery"