Class: Arel::Visitors::HSQLDB

Inherits:
ToSql
  • Object
show all
Defined in:
lib/arel/visitors/hsqldb.rb

Direct Known Subclasses

H2

Instance Method Summary collapse

Instance Method Details

#limit_offset(sql, o) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/arel/visitors/hsqldb.rb', line 19

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} 0 #{sql[7..-1]}" # removes "SELECT "
  else
    sql
  end
end

#visit_Arel_Nodes_SelectStatement(o, a = nil) ⇒ Object



6
7
8
9
# File 'lib/arel/visitors/hsqldb.rb', line 6

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