aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/sql/core_extensions/array.rb
blob: 05a1bb774c1cd172efca2edf6d748dfb4f5cde6b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Arel
  module Sql
    module ArrayExtensions
      def to_sql(formatter = nil)
        if any?
          "(" + collect { |e| e.to_sql(formatter) }.join(', ') + ")"
        else
          "(NULL)"
        end
      end

      def inclusion_predicate_sql
        "IN"
      end

      def exclusion_predicate_sql
        "NOT IN"
      end

      Array.send(:include, self)
    end
  end
end