visit_Arel_Nodes_SelectStatement(o, collector)private
No documentation available.
# File activerecord/lib/arel/visitors/mssql.rb, line 45
def visit_Arel_Nodes_SelectStatement(o, collector)
if !o.limit && !o.offset
return super
end
is_select_count = false
o.cores.each { |x|
core_order_by = row_num_literal determine_order_by(o.orders, x)
if select_count? x
x.projections = [core_order_by]
is_select_count = true
else
x.projections << core_order_by
end
}
if is_select_count
# fixme count distinct wouldn't work with limit or offset
collector << "SELECT COUNT(1) as count_id FROM ("
end
collector << "SELECT _t.* FROM ("
collector = o.cores.inject(collector) { |c, x|
visit_Arel_Nodes_SelectCore x, c
}
collector << ") as _t WHERE #{get_offset_limit_clause(o)}"
if is_select_count
collector << ") AS subquery"
else
collector
end
end