from(*indices)
click to toggle source
def from(*indices)
@indices += indices
self
end
group_by(attribute)
click to toggle source
def group_by(attribute)
@group_by = attribute
self
end
limit(limit)
click to toggle source
def limit(limit)
@limit = limit
self
end
matching(match)
click to toggle source
def matching(match)
@matching = match
self
end
offset(offset)
click to toggle source
def offset(offset)
@offset = offset
self
end
order_by(order)
click to toggle source
def order_by(order)
@order_by = order
self
end
order_within_group_by(order)
click to toggle source
def order_within_group_by(order)
@order_within_group_by = order
self
end
to_sql()
click to toggle source
def to_sql
sql = "SELECT #{ @values.join(', ') } FROM #{ @indices.join(', ') }"
sql << " WHERE #{ combined_wheres }" if wheres?
sql << " GROUP BY #{@group_by}" if !@group_by.nil?
sql << " ORDER BY #{@order_by}" if !@order_by.nil?
unless @order_within_group_by.nil?
sql << " WITHIN GROUP ORDER BY #{@order_within_group_by}"
end
sql << " #{limit_clause}" unless @limit.nil? && @offset.nil?
sql << " #{options_clause}" unless @options.empty?
sql
end
values(*values)
click to toggle source
def values(*values)
@values += values
self
end
where(filters = {})
click to toggle source
def where(filters = {})
@wheres.merge!(filters)
self
end
where_all(filters = {})
click to toggle source
def where_all(filters = {})
@where_alls.merge!(filters)
self
end
where_not(filters = {})
click to toggle source
def where_not(filters = {})
@where_nots.merge!(filters)
self
end
where_not_all(filters = {})
click to toggle source
def where_not_all(filters = {})
@where_not_alls.merge!(filters)
self
end
with_options(options = {})
click to toggle source
def with_options(options = {})
@options.merge! options
self
end