Module Sequel::Dataset::SplitArrayNil
In: lib/sequel/extensions/split_array_nil.rb

Methods

Public Instance methods

Over the IN/NOT IN handling with an array of values where one of the values in the array is nil, by removing nils from the array of values, and using a separate OR IS NULL clause for IN or AND IS NOT NULL clause for NOT IN.

[Source]

    # File lib/sequel/extensions/split_array_nil.rb, line 41
41:       def complex_expression_sql_append(sql, op, args)
42:       case op
43:       when :IN, "NOT IN""NOT IN"
44:         vals = args.at(1)
45:         if vals.is_a?(Array) && vals.any?{|v| v.nil?}
46:           cols = args.at(0)
47:           vals = vals.compact
48:           c = Sequel::SQL::BooleanExpression
49:           if op == :IN
50:             literal_append(sql, c.new(:OR, c.new(:IN, cols, vals), c.new(:IS, cols, nil)))
51:           else
52:             literal_append(sql, c.new(:AND, c.new("NOT IN""NOT IN", cols, vals), c.new("IS NOT""IS NOT", cols, nil)))
53:           end
54:         else
55:           super
56:         end
57:       else
58:         super
59:       end
60:       end

[Validate]