From b2fb1d3381027176505e8709acd22295fb57597a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 8 Apr 2014 17:16:21 -0700 Subject: postgresql visitor is working --- lib/arel/visitors/postgresql.rb | 21 +++++++++++---------- lib/arel/visitors/to_sql.rb | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb index 49f7482e7d..60878ddd20 100644 --- a/lib/arel/visitors/postgresql.rb +++ b/lib/arel/visitors/postgresql.rb @@ -3,24 +3,25 @@ module Arel class PostgreSQL < Arel::Visitors::ToSql private - def visit_Arel_Nodes_Matches o - "#{visit o.left} ILIKE #{visit o.right}" + def visit_Arel_Nodes_Matches o, collector + infix_value o, collector, ' ILIKE ' end - def visit_Arel_Nodes_DoesNotMatch o - "#{visit o.left} NOT ILIKE #{visit o.right}" + def visit_Arel_Nodes_DoesNotMatch o, collector + infix_value o, collector, ' NOT ILIKE ' end - def visit_Arel_Nodes_Regexp o - "#{visit o.left} ~ #{visit o.right}" + def visit_Arel_Nodes_Regexp o, collector + infix_value o, collector, ' ~ ' end - def visit_Arel_Nodes_NotRegexp o - "#{visit o.left} !~ #{visit o.right}" + def visit_Arel_Nodes_NotRegexp o, collector + infix_value o, collector, ' !~ ' end - def visit_Arel_Nodes_DistinctOn o - "DISTINCT ON ( #{visit o.expr} )" + def visit_Arel_Nodes_DistinctOn o, collector + collector << "DISTINCT ON ( " + visit(o.expr, collector) << " )" end end end diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 0dbec61212..8e254d504b 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -275,8 +275,8 @@ module Arel visit o.expr end - def visit_Arel_Nodes_Distinct o - DISTINCT + def visit_Arel_Nodes_Distinct o, collector + collector << DISTINCT end def visit_Arel_Nodes_DistinctOn o, collector -- cgit v1.2.3