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 42
42:       def complex_expression_sql_append(sql, op, args)
43:       case op
44:       when :IN, "NOT IN""NOT IN"
45:         vals = args.at(1)
46:         if vals.is_a?(Array) && vals.any?{|v| v.nil?}
47:           cols = args.at(0)
48:           vals = vals.compact
49:           c = Sequel::SQL::BooleanExpression
50:           if op == :IN
51:             literal_append(sql, c.new(:OR, c.new(:IN, cols, vals), c.new(:IS, cols, nil)))
52:           else
53:             literal_append(sql, c.new(:AND, c.new("NOT IN""NOT IN", cols, vals), c.new("IS NOT""IS NOT", cols, nil)))
54:           end
55:         else
56:           super
57:         end
58:       else
59:         super
60:       end
61:       end

[Validate]