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