From 85da41912e35eb4c00e10315ecae5edda2c58d4b Mon Sep 17 00:00:00 2001 From: Martin Little Date: Mon, 16 May 2011 08:56:54 -0400 Subject: Added initial informix visitor support --- lib/arel/visitors/informix.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/arel/visitors/informix.rb (limited to 'lib/arel') diff --git a/lib/arel/visitors/informix.rb b/lib/arel/visitors/informix.rb new file mode 100644 index 0000000000..cd2ec5d265 --- /dev/null +++ b/lib/arel/visitors/informix.rb @@ -0,0 +1,40 @@ +module Arel + module Visitors + class Informix < Arel::Visitors::ToSql + @skip = nil + @first = nil + private + def visit_Arel_Nodes_SelectStatement o +# @skip = o.offset if o.offset +# @first = o.limit if o.limit + [ + "SELECT", + (visit(o.offset) if o.offset), + (visit(o.limit) if o.limit), + o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join, + ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?), + (visit(o.lock) if o.lock), + ].compact.join ' ' + end + def visit_Arel_Nodes_SelectCore o + # s,f = @skip,@first + # @skip, @first = nil,nil + [ + "#{o.projections.map { |x| visit x }.join ', '}", + ("FROM #{visit o.froms}" if o.froms), + ("WHERE #{o.wheres.map { |x| visit x }.join ' AND ' }" unless o.wheres.empty?), + ("GROUP BY #{o.groups.map { |x| visit x }.join ', ' }" unless o.groups.empty?), + (visit(o.having) if o.having), + ].compact.join ' ' + end + #(visit(o.offset) if o.offset) + def visit_Arel_Nodes_Offset o + "SKIP #{visit o.expr}" + end + def visit_Arel_Nodes_Limit o + "LIMIT #{visit o.expr}" + end + end + end +end + -- cgit v1.2.3