Class: ActiveRecord::ConnectionAdapters::Mysql2Adapter
- Inherits:
-
AbstractMysqlAdapter
- Object
- AbstractAdapter
- AbstractMysqlAdapter
- ActiveRecord::ConnectionAdapters::Mysql2Adapter
- Defined in:
- lib/active_record/connection_adapters/mysql2_adapter.rb
Constant Summary collapse
- ADAPTER_NAME =
'Mysql2'.freeze
Constants inherited from AbstractMysqlAdapter
AbstractMysqlAdapter::CHARSETS_OF_4BYTES_MAXLEN, AbstractMysqlAdapter::INDEX_TYPES, AbstractMysqlAdapter::INDEX_USINGS, AbstractMysqlAdapter::NATIVE_DATABASE_TYPES
Constants inherited from AbstractAdapter
Instance Attribute Summary
Attributes inherited from AbstractAdapter
#logger, #owner, #pool, #prepared_statements, #schema_cache, #visitor
Attributes included from QueryCache
#query_cache, #query_cache_enabled
Attributes included from DatabaseStatements
Instance Method Summary collapse
-
#active? ⇒ Boolean
– CONNECTION MANAGEMENT ==================================== ++.
-
#disconnect! ⇒ Object
Disconnects from the database if already connected.
-
#each_hash(result) ⇒ Object
HELPER METHODS ===========================================.
- #error_number(exception) ⇒ Object
-
#initialize(connection, logger, connection_options, config) ⇒ Mysql2Adapter
constructor
A new instance of Mysql2Adapter.
-
#quote_string(string) ⇒ Object
– QUOTING ================================================== ++.
- #reconnect! ⇒ Object (also: #reset!)
- #supports_comments? ⇒ Boolean
- #supports_comments_in_create? ⇒ Boolean
- #supports_json? ⇒ Boolean
- #supports_savepoints? ⇒ Boolean
Methods included from ActiveRecord::ConnectionAdapters::MySQL::DatabaseStatements
#exec_delete, #exec_query, #execute, #select_all, #select_one, #select_rows
Methods inherited from AbstractMysqlAdapter
#add_index, #add_sql_comment!, #arel_visitor, #begin_db_transaction, #begin_isolated_db_transaction, #bulk_change_table, #case_sensitive_comparison, #change_column, #change_column_default, #change_column_null, #charset, #clear_cache!, #collation, #columns, #columns_for_distinct, #commit_db_transaction, #create_database, #create_table, #current_database, #data_source_exists?, #data_sources, #disable_referential_integrity, #drop_database, #drop_table, #empty_insert_statement_value, #emulate_booleans, #exec_rollback_db_transaction, #execute, #execute_and_free, #explain, #foreign_keys, #get_advisory_lock, #index_algorithms, #indexes, #internal_string_options_for_primary_key, #join_to_update, #mariadb?, #native_database_types, #new_column, #primary_keys, #recreate_database, #release_advisory_lock, #rename_column, #rename_index, #rename_table, #schema_creation, #show_variable, #strict_mode?, #supports_advisory_locks?, #supports_bulk_alter?, #supports_datetime_with_precision?, #supports_explain?, #supports_foreign_keys?, #supports_index_sort_order?, #supports_indexes_in_create?, #supports_migrations?, #supports_primary_key?, #supports_statement_cache?, #supports_transaction_isolation?, #supports_views?, #table_comment, #table_exists?, #table_options, #tables, #truncate, #type_to_sql, #update_table_definition, #valid_type?, #version, #view_exists?, #views
Methods included from ActiveRecord::ConnectionAdapters::MySQL::ColumnDumper
#column_spec_for_primary_key, #migration_keys, #prepare_column_options
Methods included from ActiveRecord::ConnectionAdapters::MySQL::Quoting
#quote_column_name, #quote_table_name, #quoted_date, #quoted_false, #quoted_true, #unquoted_false, #unquoted_true
Methods inherited from AbstractAdapter
#adapter_name, #arel_visitor, #case_insensitive_comparison, #case_sensitive_comparison, #clear_cache!, #close, #collector, #column_name_for_operation, #combine_bind_parameters, #disable_extension, #disable_referential_integrity, #enable_extension, #expire, #extensions, #get_advisory_lock, #index_algorithms, #lease, #lookup_cast_type, #new_column, #prefetch_primary_key?, #raw_connection, #release_advisory_lock, #requires_reloading?, #schema_creation, #supports_advisory_locks?, #supports_bulk_alter?, #supports_datetime_with_precision?, #supports_ddl_transactions?, #supports_explain?, #supports_expression_index?, #supports_extensions?, #supports_index_sort_order?, #supports_migrations?, #supports_multi_insert?, #supports_partial_index?, #supports_primary_key?, #supports_transaction_isolation?, #supports_views?, type_cast_config_to_boolean, type_cast_config_to_integer, #type_map, #unprepared_statement, #valid_type?, #verify!
Methods included from Savepoints
#create_savepoint, #current_savepoint_name, #exec_rollback_to_savepoint, #release_savepoint
Methods included from ColumnDumper
#column_spec, #column_spec_for_primary_key, #migration_keys, #prepare_column_options
Methods included from QueryCache
#cache, #clear_query_cache, dirties_query_cache, #disable_query_cache!, #enable_query_cache!, included, #select_all, #uncached
Methods included from DatabaseLimits
#allowed_index_name_length, #column_name_length, #columns_per_multicolumn_index, #columns_per_table, #in_clause_length, #index_name_length, #indexes_per_table, #joins_per_query, #sql_query_length, #table_alias_length, #table_name_length
Methods included from Quoting
#fetch_type_metadata, #lookup_cast_type_from_column, #prepare_binds_for_database, #quote, #quote_column_name, #quote_default_expression, #quote_table_name, #quote_table_name_for_assignment, #quoted_date, #quoted_false, #quoted_time, #quoted_true, #type_cast, #type_cast_from_column, #unquoted_false, #unquoted_true
Methods included from DatabaseStatements
#add_transaction_record, #begin_db_transaction, #begin_isolated_db_transaction, #cacheable_query, #commit_db_transaction, #default_sequence_name, #delete, #empty_insert_statement_value, #exec_delete, #exec_insert, #exec_query, #exec_rollback_db_transaction, #exec_update, #execute, #insert, #insert_fixture, #join_to_update, #reset_sequence!, #reset_transaction, #rollback_db_transaction, #rollback_to_savepoint, #sanitize_limit, #select_all, #select_one, #select_rows, #select_value, #select_values, #supports_statement_cache?, #to_sql, #transaction, #transaction_isolation_levels, #transaction_open?, #transaction_state, #truncate, #update
Methods included from SchemaStatements
#add_column, #add_foreign_key, #add_index, #add_index_options, #add_reference, #add_timestamps, #assume_migrated_upto_version, #change_column, #change_column_comment, #change_column_default, #change_column_null, #change_table, #change_table_comment, #column_exists?, #columns, #columns_for_distinct, #create_join_table, #create_table, #data_source_exists?, #data_sources, #drop_join_table, #drop_table, #dump_schema_information, #foreign_key_column_for, #foreign_key_exists?, #foreign_key_for, #foreign_key_for!, #foreign_key_options, #foreign_keys, #index_exists?, #index_name, #index_name_exists?, #initialize_internal_metadata_table, #initialize_schema_migrations_table, #insert_versions_sql, #internal_string_options_for_primary_key, #native_database_types, #options_include_default?, #primary_key, #remove_column, #remove_columns, #remove_foreign_key, #remove_index, #remove_reference, #remove_timestamps, #rename_column, #rename_index, #rename_table, #table_alias_for, #table_comment, #table_exists?, #table_options, #tables, #type_to_sql, #update_table_definition, #view_exists?, #views
Constructor Details
#initialize(connection, logger, connection_options, config) ⇒ Mysql2Adapter
Returns a new instance of Mysql2Adapter.
42 43 44 45 46 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 42 def initialize(connection, logger, , config) super @prepared_statements = false unless config.key?(:prepared_statements) configure_connection end |
Instance Method Details
#active? ⇒ Boolean
– CONNECTION MANAGEMENT ==================================== ++
92 93 94 95 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 92 def active? return false unless @connection @connection.ping end |
#disconnect! ⇒ Object
Disconnects from the database if already connected. Otherwise, this method does nothing.
106 107 108 109 110 111 112 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 106 def disconnect! super unless @connection.nil? @connection.close @connection = nil end end |
#each_hash(result) ⇒ Object
HELPER METHODS ===========================================
66 67 68 69 70 71 72 73 74 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 66 def each_hash(result) # :nodoc: if block_given? result.each(:as => :hash, :symbolize_keys => true) do |row| yield row end else to_enum(:each_hash, result) end end |
#error_number(exception) ⇒ Object
76 77 78 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 76 def error_number(exception) exception.error_number if exception.respond_to?(:error_number) end |
#quote_string(string) ⇒ Object
– QUOTING ================================================== ++
84 85 86 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 84 def quote_string(string) @connection.escape(string) end |
#reconnect! ⇒ Object Also known as: reset!
97 98 99 100 101 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 97 def reconnect! super disconnect! connect end |
#supports_comments? ⇒ Boolean
52 53 54 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 52 def supports_comments? true end |
#supports_comments_in_create? ⇒ Boolean
56 57 58 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 56 def supports_comments_in_create? true end |
#supports_json? ⇒ Boolean
48 49 50 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 48 def supports_json? !mariadb? && version >= '5.7.8' end |
#supports_savepoints? ⇒ Boolean
60 61 62 |
# File 'lib/active_record/connection_adapters/mysql2_adapter.rb', line 60 def supports_savepoints? true end |