class ActiveRecord::ConnectionAdapters::Mysql2Adapter

Constants

ADAPTER_NAME

Public Class Methods

new(connection, logger, connection_options, config) click to toggle source
Calls superclass method ArJdbc::Abstract::StatementCache::new
# File lib/arjdbc/mysql/adapter.rb, line 33
def initialize(connection, logger, connection_options, config)
  super(connection, logger, config)

  @prepared_statements = false unless config.key?(:prepared_statements)

  configure_connection
end

Public Instance Methods

clear_cache!() click to toggle source

Reloading the type map in abstract/statement_cache.rb blows up postgres

# File lib/arjdbc/mysql/adapter.rb, line 60
def clear_cache!
  reload_type_map
  super
end
error_number(exception) click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 78
def error_number(exception)
  exception.errno if exception.respond_to? :errno
end
exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil) click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 102
def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)
  last_id = if without_prepared_statement?(binds)
              log(sql, name) { @connection.execute_insert(sql) }
            else
              log(sql, name, binds) { @connection.execute_insert(sql, binds) }
            end
  # FIXME: execute_insert and executeUpdate mapping key results is very varied and I am wondering
  # if AR is now much more consistent.  I worked around by manually making a result here.
  ::ActiveRecord::Result.new(nil, [[last_id]])
end
Also aliased as: insert_sql
insert_sql(sql, name = nil, binds = [], pk = nil, sequence_name = nil)
Alias for: exec_insert
quote(value, comment=nil) click to toggle source

FIXME: 5.1 crashes without this. I think this is Arel hitting a fallback path in to_sql.rb. So maybe an untested code path in their source. Still means we are doing something wrong to even hit it.

Calls superclass method
# File lib/arjdbc/mysql/adapter.rb, line 94
def quote(value, comment=nil)
  super(value)
end
quote_string(string) click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 98
def quote_string(string)
  string.gsub(/[\x00\n\r\\\'\"]/, '\\\\\0')
end
supports_comments?() click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 45
def supports_comments?
  true
end
supports_comments_in_create?() click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 49
def supports_comments_in_create?
  true
end
supports_json?() click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 41
def supports_json?
  !mariadb? && version >= '5.7.8'
end
supports_savepoints?() click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 53
def supports_savepoints?
  true
end

Private Instance Methods

full_version() click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 117
def full_version
  @full_version ||= begin
    result = execute 'SELECT VERSION()', 'SCHEMA'
    result.first.values.first # [{"VERSION()"=>"5.5.37-0ubuntu..."}]
  end
end
jdbc_column_class() click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 128
def jdbc_column_class
  ::ActiveRecord::ConnectionAdapters::MySQL::Column
end
jdbc_connection_class(spec) click to toggle source
# File lib/arjdbc/mysql/adapter.rb, line 124
def jdbc_connection_class(spec)
  ::ActiveRecord::ConnectionAdapters::MySQLJdbcConnection
end