class ActiveRecord::ConnectionAdapters::Mysql2Adapter

Constants

ADAPTER_NAME

Public Class Methods

new(connection, logger, connection_options, config) click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 40
def initialize(connection, logger, connection_options, config)
  super
  @prepared_statements = false unless config.key?(:prepared_statements)
  configure_connection
end

Public Instance Methods

active?() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 90
def active?
  @connection.ping
end
disconnect!() click to toggle source

Disconnects from the database if already connected. Otherwise, this method does nothing.

# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 103
def disconnect!
  super
  @connection.close
end
error_number(exception) click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 74
def error_number(exception)
  exception.error_number if exception.respond_to?(:error_number)
end
quote_string(string) click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 82
def quote_string(string)
  @connection.escape(string)
end
reconnect!() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 94
def reconnect!
  super
  disconnect!
  connect
end
Also aliased as: reset!
reset!()
Alias for: reconnect!
supports_comments?() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 50
def supports_comments?
  true
end
supports_comments_in_create?() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 54
def supports_comments_in_create?
  true
end
supports_json?() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 46
def supports_json?
  !mariadb? && version >= "5.7.8"
end
supports_savepoints?() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 58
def supports_savepoints?
  true
end

Private Instance Methods

configure_connection() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 115
def configure_connection
  @connection.query_options.merge!(as: :array)
  super
end
connect() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 110
def connect
  @connection = Mysql2::Client.new(@config)
  configure_connection
end
full_version() click to toggle source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 120
def full_version
  @full_version ||= @connection.server_info[:version]
end