module Sequel::Postgres::AutoParameterizeInArray
def complex_expression_sql_append(sql, op, args)
This is the same optimization PostgreSQL performs internally,
the type is handled by the extension.
if all values inside the predicate are of the same type and
using an array bound variable for the ANY/ALL argument,
and column NOT IN (...) expressions into column != ALL($)
Transform column IN (...) expressions into column = ANY($)
def complex_expression_sql_append(sql, op, args) case op when :IN, :"NOT IN" l, r = args if auto_param?(sql) && (type = _bound_variable_type_for_array(r)) if op == :IN op = :"=" func = :ANY else op = :!= func = :ALL end args = [l, Sequel.function(func, _convert_array_to_pg_array_with_type(r, type))] end end super end