Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/mysql2legacydb_adapter.rb

Class Method Summary collapse

Class Method Details

.mysql2legacydb_connection(config) ⇒ Object

same as “def.self.mysql2_connection(config)” in mysql2 gem except that the ConnectionAdapter returned is a Mysql2LegacyAdapter instead of a regular Mysql2Adapter



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/active_record/connection_adapters/mysql2legacydb_adapter.rb', line 7

def self.mysql2legacydb_connection(config)
  config[:username] = 'root' if config[:username].nil?

  if Mysql2::Client.const_defined? :FOUND_ROWS
    config[:flags] = Mysql2::Client::FOUND_ROWS
  end

  client = Mysql2::Client.new(config.symbolize_keys)
  options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0]
  ConnectionAdapters::Mysql2LegacyDBAdapter.new(client, logger, options, config)
end