class ActiveRecord::ConnectionAdapters::DepartureAdapter

Constants

ADAPTER_NAME

Attributes

mysql_adapter[R]

Public Class Methods

new(connection, _logger, connection_options, _config) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/percona_adapter.rb, line 71
def initialize(connection, _logger, connection_options, _config)
  @mysql_adapter = connection_options[:mysql_adapter]
  super
  @prepared_statements = false
end

Public Instance Methods

add_index(table_name, column_name, options = {}) click to toggle source

Adds a new index to the table

@param table_name [String, Symbol] @param column_name [String, Symbol] @param options [Hash] optional

# File lib/active_record/connection_adapters/percona_adapter.rb, line 121
def add_index(table_name, column_name, options = {})
  index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, options)
  execute "ALTER TABLE #{quote_table_name(table_name)} ADD #{index_type} INDEX #{quote_column_name(index_name)} (#{index_columns})#{index_options}" # rubocop:disable Metrics/LineLength
end
change_table(table_name, _options = {}) { |update_table_definition(table_name, recorder)| ... } click to toggle source
# File lib/active_record/connection_adapters/percona_adapter.rb, line 139
def change_table(table_name, _options = {})
  recorder = ActiveRecord::Migration::CommandRecorder.new(self)
  yield update_table_definition(table_name, recorder)
  bulk_change_table(table_name, recorder.commands)
end
error_number(_exception) click to toggle source

Returns the MySQL error number from the exception. The AbstractMysqlAdapter requires it to be implemented

# File lib/active_record/connection_adapters/percona_adapter.rb, line 147
def error_number(_exception); end
exec_delete(sql, name, binds) click to toggle source
# File lib/active_record/connection_adapters/percona_adapter.rb, line 77
def exec_delete(sql, name, binds)
  execute(to_sql(sql, binds), name)
  @connection.affected_rows
end
Also aliased as: exec_update
exec_insert(sql, name, binds, pk = nil, sequence_name = nil) click to toggle source
# File lib/active_record/connection_adapters/percona_adapter.rb, line 83
def exec_insert(sql, name, binds, pk = nil, sequence_name = nil) # rubocop:disable Lint/UnusedMethodArgument, Metrics/LineLength
  execute(to_sql(sql, binds), name)
end
exec_query(sql, name = 'SQL', _binds = []) click to toggle source
# File lib/active_record/connection_adapters/percona_adapter.rb, line 87
def exec_query(sql, name = 'SQL', _binds = [])
  result = execute(sql, name)
  ActiveRecord::Result.new(result.fields, result.to_a)
end
exec_update(sql, name, binds)
Alias for: exec_delete
full_version() click to toggle source
# File lib/active_record/connection_adapters/percona_adapter.rb, line 149
def full_version
  if ActiveRecord::VERSION::MAJOR < 6
    get_full_version
  else
    schema_cache.database_version.full_version_string
  end
end
get_full_version() click to toggle source

This is a method defined in Rails 6.0, and we have no control over the naming of this method.

# File lib/active_record/connection_adapters/percona_adapter.rb, line 159
def get_full_version # rubocop:disable Naming/AccessorMethodName
  mysql_adapter.raw_connection.server_info[:version]
end
new_column(field, default, type_metadata, null, table_name, default_function, collation, comment) click to toggle source

rubocop:disable Metrics/ParameterLists

# File lib/active_record/connection_adapters/percona_adapter.rb, line 111
def new_column(field, default, type_metadata, null, table_name, default_function, collation, comment)
  Column.new(field, default, type_metadata, null, table_name, default_function, collation, comment)
end
remove_index(table_name, options = {}) click to toggle source

Remove the given index from the table.

@param table_name [String, Symbol] @param options [Hash] optional

# File lib/active_record/connection_adapters/percona_adapter.rb, line 130
def remove_index(table_name, options = {})
  index_name = index_name_for_remove(table_name, options)
  execute "ALTER TABLE #{quote_table_name(table_name)} DROP INDEX #{quote_column_name(index_name)}"
end
schema_creation() click to toggle source
# File lib/active_record/connection_adapters/percona_adapter.rb, line 135
def schema_creation
  SchemaCreation.new(self)
end
select(sql, name = nil, binds = []) click to toggle source

Executes a SELECT query and returns an array of record hashes with the column names as keys and column values as values.

# File lib/active_record/connection_adapters/percona_adapter.rb, line 101
def select(sql, name = nil, binds = [])
  exec_query(sql, name, binds)
end
select_rows(arel, name = nil, binds = []) click to toggle source

Executes a SELECT query and returns an array of rows. Each row is an array of field values.

# File lib/active_record/connection_adapters/percona_adapter.rb, line 95
def select_rows(arel, name = nil, binds = [])
  select_all(arel, name, binds).rows
end
supports_migrations?() click to toggle source

Returns true, as this adapter supports migrations

# File lib/active_record/connection_adapters/percona_adapter.rb, line 106
def supports_migrations?
  true
end