Class: ActiveRecord::ConnectionAdapters::ArrivalAdapter
- Inherits:
-
AbstractMysqlAdapter
- Object
- AbstractMysqlAdapter
- ActiveRecord::ConnectionAdapters::ArrivalAdapter
- Extended by:
- Forwardable
- Includes:
- ForAlterStatements
- Defined in:
- lib/active_record/connection_adapters/arrival_adapter.rb
Defined Under Namespace
Classes: Column, SchemaCreation
Constant Summary collapse
- ADAPTER_NAME =
'Arrival'.freeze
Instance Method Summary collapse
-
#add_index(table_name, column_name, options = {}) ⇒ Object
Adds a new index to the table.
- #change_table(table_name, _options = {}) {|update_table_definition(table_name, recorder)| ... } ⇒ Object
-
#error_number(_exception) ⇒ Object
Returns the MySQL error number from the exception.
- #exec_delete(sql, name, binds) ⇒ Object (also: #exec_update)
-
#exec_insert(sql, name, binds, pk = nil, sequence_name = nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument, Metrics/LineLength.
- #exec_query(sql, name = 'SQL', _binds = []) ⇒ Object
- #full_version ⇒ Object
-
#initialize(connection, _logger, connection_options, _config) ⇒ ArrivalAdapter
constructor
A new instance of ArrivalAdapter.
-
#new_column(field, default, type_metadata, null, table_name, default_function, collation, comment) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
#remove_index(table_name, options = {}) ⇒ Object
Remove the given index from the table.
- #schema_creation ⇒ Object
-
#select(sql, name = nil, binds = []) ⇒ Object
Executes a SELECT query and returns an array of record hashes with the column names as keys and column values as values.
-
#select_rows(arel, name = nil, binds = []) ⇒ Object
Executes a SELECT query and returns an array of rows.
-
#supports_migrations? ⇒ Boolean
Returns true, as this adapter supports migrations.
Methods included from ForAlterStatements
#add_column_for_alter, #add_index_for_alter, #add_timestamps_for_alter, #bulk_change_table, #change_column_for_alter, included, #remove_column_for_alter, #remove_columns_for_alter, #remove_index_for_alter, #remove_timestamps_for_alter, #rename_column_for_alter
Constructor Details
#initialize(connection, _logger, connection_options, _config) ⇒ ArrivalAdapter
Returns a new instance of ArrivalAdapter.
66 67 68 69 70 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 66 def initialize(connection, _logger, , _config) @mysql_adapter = [:mysql_adapter] super @prepared_statements = false end |
Instance Method Details
#add_index(table_name, column_name, options = {}) ⇒ Object
Adds a new index to the table
116 117 118 119 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 116 def add_index(table_name, column_name, = {}) index_name, index_type, index_columns, = (table_name, column_name, ) 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)| ... } ⇒ Object
134 135 136 137 138 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 134 def change_table(table_name, = {}) recorder = ActiveRecord::Migration::CommandRecorder.new(self) yield update_table_definition(table_name, recorder) bulk_change_table(table_name, recorder.commands) end |
#error_number(_exception) ⇒ Object
Returns the MySQL error number from the exception. The AbstractMysqlAdapter requires it to be implemented
142 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 142 def error_number(_exception); end |
#exec_delete(sql, name, binds) ⇒ Object Also known as: exec_update
72 73 74 75 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 72 def exec_delete(sql, name, binds) execute(to_sql(sql, binds), name) @connection.affected_rows end |
#exec_insert(sql, name, binds, pk = nil, sequence_name = nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument, Metrics/LineLength
78 79 80 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 78 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 = []) ⇒ Object
82 83 84 85 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 82 def exec_query(sql, name = 'SQL', _binds = []) result = execute(sql, name) ActiveRecord::Result.new(result.fields, result.to_a) end |
#full_version ⇒ Object
144 145 146 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 144 def full_version mysql_adapter.raw_connection.server_info[:version] end |
#new_column(field, default, type_metadata, null, table_name, default_function, collation, comment) ⇒ Object
rubocop:disable Metrics/ParameterLists
106 107 108 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 106 def new_column(field, default, , null, table_name, default_function, collation, comment) Column.new(field, default, , null, table_name, default_function, collation, comment) end |
#remove_index(table_name, options = {}) ⇒ Object
Remove the given index from the table.
125 126 127 128 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 125 def remove_index(table_name, = {}) index_name = index_name_for_remove(table_name, ) execute "ALTER TABLE #{quote_table_name(table_name)} DROP INDEX #{quote_column_name(index_name)}" end |
#schema_creation ⇒ Object
130 131 132 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 130 def schema_creation SchemaCreation.new(self) end |
#select(sql, name = nil, binds = []) ⇒ Object
Executes a SELECT query and returns an array of record hashes with the column names as keys and column values as values.
96 97 98 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 96 def select(sql, name = nil, binds = []) exec_query(sql, name, binds) end |
#select_rows(arel, name = nil, binds = []) ⇒ Object
Executes a SELECT query and returns an array of rows. Each row is an array of field values.
90 91 92 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 90 def select_rows(arel, name = nil, binds = []) select_all(arel, name, binds).rows end |
#supports_migrations? ⇒ Boolean
Returns true, as this adapter supports migrations
101 102 103 |
# File 'lib/active_record/connection_adapters/arrival_adapter.rb', line 101 def supports_migrations? true end |