Module: Sequel::Dataset::SplitArrayNil
- Defined in:
- lib/sequel/extensions/split_array_nil.rb
Instance Method Summary collapse
- 
  
    
      #complex_expression_sql_append(sql, op, args)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    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. 
Instance Method Details
#complex_expression_sql_append(sql, op, args) ⇒ Object
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.
| 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # File 'lib/sequel/extensions/split_array_nil.rb', line 46 def complex_expression_sql_append(sql, op, args) case op when :IN, :"NOT IN" vals = args[1] if vals.is_a?(Array) && vals.any?(&:nil?) cols = args[0] vals = vals.compact c = Sequel::SQL::BooleanExpression if op == :IN literal_append(sql, c.new(:OR, c.new(:IN, cols, vals), c.new(:IS, cols, nil))) else literal_append(sql, c.new(:AND, c.new(:"NOT IN", cols, vals), c.new(:"IS NOT", cols, nil))) end else super end else super end end |