Module: ActiveRecord::ConnectionHandling

Defined in:
lib/active_record/connection_adapters/tidb_adapter.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#tidb_connection(config) ⇒ Object

Establishes a connection to the database that’s used by all Active Record objects.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/active_record/connection_adapters/tidb_adapter.rb', line 16

def tidb_connection(config) # :nodoc:
  config = config.symbolize_keys
  config[:flags] ||= 0

  if config[:flags].is_a? Array
    config[:flags].push 'FOUND_ROWS'
  else
    config[:flags] |= Mysql2::Client::FOUND_ROWS
  end

  ConnectionAdapters::TidbAdapter.new(
    ConnectionAdapters::Mysql2Adapter.new_client(config),
    logger,
    nil,
    config
  )
end