class ActiveRecord::ConnectionAdapters::PedantMysql2Adapter

Public Instance Methods

exec_delete(sql, name, binds) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/pedant_mysql2_adapter.rb, line 68
def exec_delete(sql, name, binds)
  @affected_rows_before_logging = nil
  value = super
  @affected_rows_before_logging || value
end
Also aliased as: exec_update
exec_update(sql, name, binds)
Alias for: exec_delete
execute(sql, *) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/pedant_mysql2_adapter.rb, line 61
def execute(sql, *)
  value = super
  log_warnings(sql)
  value
end

Private Instance Methods

log_warnings(sql) click to toggle source
# File lib/active_record/connection_adapters/pedant_mysql2_adapter.rb, line 78
def log_warnings(sql)
  # support for https://github.com/rails/rails/commit/d86fd6415c0dfce6fadb77e74696cf728e5eb76b
  connection = instance_variable_defined?(:@raw_connection) ? @raw_connection : @connection

  return unless connection.warning_count > 0

  @affected_rows_before_logging = connection.affected_rows
  result = connection.query('SHOW WARNINGS')

  result.each do |level, code, message|
    warning = MysqlWarning.new(message, code, level, sql)
    ::PedantMysql2.warn(warning)
  end
end