Method: Sequel::Postgres::AutoParameterize::DatasetMethods#cast_sql_append

Defined in:
lib/sequel/extensions/pg_auto_parameterize.rb

#cast_sql_append(sql, expr, type) ⇒ Object

Do not add implicit typecasts for directly typecasted values, since the user is presumably doing so to set the type, not convert from the implicitly typecasted type.



258
259
260
261
262
263
264
265
266
# File 'lib/sequel/extensions/pg_auto_parameterize.rb', line 258

def cast_sql_append(sql, expr, type)
  if auto_param?(sql) && auto_param_type(expr)
    sql << 'CAST('
    sql.add_arg(expr)
    sql << ' AS ' << db.cast_type_literal(type).to_s << ')'
  else
    super
  end
end