aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/postgresql.rb
blob: 7520a1ccc79bcac83b24467338097b6c4c5c0c99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Arel
  module Visitors
    class PostgreSQL < Arel::Visitors::ToSql
      private

      def visit_Arel_Nodes_Matches o, a
        a = o.left if Arel::Attributes::Attribute === o.left
        "#{visit o.left, a} ILIKE #{visit o.right, a}"
      end

      def visit_Arel_Nodes_DoesNotMatch o, a
        a = o.left if Arel::Attributes::Attribute === o.left
        "#{visit o.left, a} NOT ILIKE #{visit o.right, a}"
      end

      def visit_Arel_Nodes_DistinctOn o, a
        "DISTINCT ON ( #{visit o.expr, a} )"
      end
    end
  end
end