Class: ActiveRecord::ConnectionAdapters::Mysql2Adapter
- Inherits:
-
AbstractMysqlAdapter
- Object
- AbstractMysqlAdapter
- ActiveRecord::ConnectionAdapters::Mysql2Adapter
- Includes:
- Jdbc::ConnectionPoolCallbacks, ArJdbc::Abstract::ConnectionManagement, ArJdbc::Abstract::DatabaseStatements, ArJdbc::Abstract::StatementCache, ArJdbc::Abstract::TransactionSupport, ArJdbc::MySQL
- Defined in:
- lib/arjdbc/mysql/adapter.rb
Constant Summary collapse
- ADAPTER_NAME =
'Mysql2'.freeze
Constants included from ArJdbc::Abstract::DatabaseStatements
ArJdbc::Abstract::DatabaseStatements::NO_BINDS
Instance Method Summary collapse
-
#clear_cache! ⇒ Object
Reloading the type map in abstract/statement_cache.rb blows up postgres.
-
#create_table(table_name, **options) ⇒ Object
:nodoc:.
-
#each_hash(result) ⇒ Object
:nodoc:.
- #error_number(exception) ⇒ Object
-
#initialize(connection, logger, connection_parameters, config) ⇒ Mysql2Adapter
constructor
A new instance of Mysql2Adapter.
-
#quoted_date(value) ⇒ Object
NOTE: quote_string(string) provided by ArJdbc::MySQL (native code), this piece is also native (mysql2) under MRI:
@connection.escape(string). - #supports_comments? ⇒ Boolean
- #supports_comments_in_create? ⇒ Boolean
- #supports_json? ⇒ Boolean
- #supports_savepoints? ⇒ Boolean
Methods included from ArJdbc::Abstract::TransactionSupport
#begin_db_transaction, #begin_isolated_db_transaction, #commit_db_transaction, #create_savepoint, #exec_rollback_db_transaction, #exec_rollback_to_savepoint, #release_savepoint, #supports_transaction_isolation?
Methods included from ArJdbc::Abstract::StatementCache
#delete_cached_statement, #fetch_cached_statement, #supports_statement_cache?
Methods included from ArJdbc::Abstract::DatabaseStatements
#exec_insert, #exec_query, #exec_update, #execute, #select_all
Methods included from ArJdbc::Abstract::ConnectionManagement
#active?, #disconnect!, #reconnect!
Methods included from Jdbc::ConnectionPoolCallbacks
Constructor Details
#initialize(connection, logger, connection_parameters, config) ⇒ Mysql2Adapter
Returns a new instance of Mysql2Adapter.
34 35 36 37 38 |
# File 'lib/arjdbc/mysql/adapter.rb', line 34 def initialize(connection, logger, connection_parameters, config) super @prepared_statements = false unless config.key?(:prepared_statements) # configure_connection taken care of at ArJdbc::Abstract::Core end |
Instance Method Details
#clear_cache! ⇒ Object
Reloading the type map in abstract/statement_cache.rb blows up postgres
59 60 61 62 |
# File 'lib/arjdbc/mysql/adapter.rb', line 59 def clear_cache! reload_type_map super end |
#create_table(table_name, **options) ⇒ Object
:nodoc:
81 82 83 |
# File 'lib/arjdbc/mysql/adapter.rb', line 81 def create_table(table_name, **) #:nodoc: super(table_name, options: "ENGINE=InnoDB", **) end |
#each_hash(result) ⇒ Object
:nodoc:
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/arjdbc/mysql/adapter.rb', line 64 def each_hash(result) # :nodoc: if block_given? # FIXME: This is C in mysql2 gem and I just made simplest Ruby result.each do |row| new_hash = {} row.each { |k, v| new_hash[k.to_sym] = v } yield new_hash end else to_enum(:each_hash, result) end end |
#error_number(exception) ⇒ Object
77 78 79 |
# File 'lib/arjdbc/mysql/adapter.rb', line 77 def error_number(exception) exception.error_code if exception.is_a?(JDBCError) end |
#quoted_date(value) ⇒ Object
NOTE: quote_string(string) provided by ArJdbc::MySQL (native code),
this piece is also native (mysql2) under MRI: @connection.escape(string)
92 93 94 95 96 97 98 |
# File 'lib/arjdbc/mysql/adapter.rb', line 92 def quoted_date(value) if supports_datetime_with_precision? super else super.sub(/\.\d{6}\z/, '') end end |
#supports_comments? ⇒ Boolean
44 45 46 |
# File 'lib/arjdbc/mysql/adapter.rb', line 44 def supports_comments? true end |
#supports_comments_in_create? ⇒ Boolean
48 49 50 |
# File 'lib/arjdbc/mysql/adapter.rb', line 48 def supports_comments_in_create? true end |
#supports_json? ⇒ Boolean
40 41 42 |
# File 'lib/arjdbc/mysql/adapter.rb', line 40 def supports_json? !mariadb? && version >= '5.7.8' end |
#supports_savepoints? ⇒ Boolean
52 53 54 |
# File 'lib/arjdbc/mysql/adapter.rb', line 52 def supports_savepoints? true end |