module Sequel::Dataset::SetLiteralizer

  1. lib/sequel/extensions/set_literalizer.rb

Methods

Public Instance

  1. complex_expression_sql_append

Public Instance methods

complex_expression_sql_append(sql, op, args)

Try to generate the same SQL for Set instances used in datasets that would be used for equivalent Array instances.

[show source]
   # File lib/sequel/extensions/set_literalizer.rb
22 def complex_expression_sql_append(sql, op, args)
23   # Array instances are treated specially by
24   # Sequel::SQL::BooleanExpression.from_value_pairs. That cannot
25   # be modified by a dataset extension, so this tries to convert
26   # the complex expression values generated by default to what would
27   # be the complex expression values used for the equivalent array.
28   case op
29   when :'=', :'!='
30     if (set = args[1]).is_a?(Set)
31       op = op == :'=' ? :IN : :'NOT IN'
32       col = args[0]
33       array = set.to_a
34       if Sequel.condition_specifier?(array) && col.is_a?(Array)
35         array = Sequel.value_list(array)
36       end
37       args = [col, array]
38     end
39   end
40 
41   super
42 end