Class: Arel::Visitors::H2

Inherits:
HSQLDB
  • Object
show all
Defined in:
lib/arel/visitors/h2.rb

Instance Method Summary collapse

Instance Method Details

#limit_offset(sql, o) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/arel/visitors/h2.rb', line 12

def limit_offset sql, o
  offset = o.offset || 0
  offset = offset.expr unless (offset.nil? || offset == 0)
  if limit = o.limit
    "SELECT LIMIT #{offset} #{limit_for(limit)} #{sql[7..-1]}"
  elsif offset > 0
    "SELECT LIMIT #{offset} -1 #{sql[7..-1]}" # removes "SELECT "
  else
    sql
  end
end

#visit_Arel_Nodes_SelectStatement(o) ⇒ Object



7
8
9
10
# File 'lib/arel/visitors/h2.rb', line 7

def visit_Arel_Nodes_SelectStatement(o, *)
  o.limit ||= Arel::Nodes::Limit.new(-1) if o.offset
  super
end