Class: Arel::Visitors::HSQLDB

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

Instance Method Summary collapse

Methods included from ArJdbcCompat

#limit_for

Instance Method Details

#limit_offset(sql, o) ⇒ Object



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

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

#visit_Arel_Nodes_SelectStatement(o) ⇒ Object



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

def visit_Arel_Nodes_SelectStatement o
  [
    limit_offset(o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join, o),
    ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?),
  ].compact.join ' '
end