Methods
A
D
F
L
P
R
S
V
Included Modules
Instance Public methods
active?()

Is this connection active and ready to perform queries?

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 68
def active?
  @active != false
end
adapter_name()

Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 35
def adapter_name
  'Abstract'
end
disconnect!()

Close this connection

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 78
def disconnect!
  @active = false
end
prefetch_primary_key?(table_name = nil)

Should primary key values be selected from their corresponding sequence before the insert statement? If true, next_sequence_value is called before each insert to set the record’s primary key. This is false for all adapters but Firebird.

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 55
def prefetch_primary_key?(table_name = nil)
  false
end
raw_connection()

Provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql’s lo_* methods

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 101
def raw_connection
  @connection
end
reconnect!()

Close this connection and open a new one in its place.

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 73
def reconnect!
  @active = true
end
requires_reloading?()

Returns true if its safe to reload the connection between requests for development mode. This is not the case for Ruby/MySQL and it’s not necessary for any adapters except SQLite.

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 84
def requires_reloading?
  false
end
supports_count_distinct?()

Does this adapter support using DISTINCT within COUNT? This is true for all adapters except sqlite.

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 47
def supports_count_distinct?
  true
end
supports_migrations?()

Does this adapter support migrations? Backend specific, as the abstract adapter always returns false.

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 41
def supports_migrations?
  false
end
verify!(timeout)

Lazily verify this connection, calling active? only if it hasn’t been called for timeout seconds.

# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 90
def verify!(timeout)
  now = Time.now.to_i
  if (now - @last_verification) > timeout
    reconnect! unless active?
    @last_verification = now
  end
end
Instance Protected methods
format_log_entry(message, dump = nil)
# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 142
def format_log_entry(message, dump = nil)
  if ActiveRecord::Base.colorize_logging
    if @@row_even
      @@row_even = false
      message_color, dump_color = "4;36;1", "0;1"
    else
      @@row_even = true
      message_color, dump_color = "4;35;1", "0"
    end

    log_entry = "  \e[#{message_color}m#{message}\e[0m   "
    log_entry << "\e[#{dump_color}m%#{String === dump ? 's' : 'p'}\e[0m" % dump if dump
    log_entry
  else
    "%s  %s" % [message, dump]
  end
end
log(sql, name)
# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 106
def log(sql, name)
  if block_given?
    if @logger and @logger.level <= Logger::INFO
      result = nil
      seconds = Benchmark.realtime { result = yield }
      @runtime += seconds
      log_info(sql, name, seconds)
      result
    else
      yield
    end
  else
    log_info(sql, name, 0)
    nil
  end
rescue Exception => e
  # Log message and raise exception.
  # Set last_verfication to 0, so that connection gets verified
  # upon reentering the request loop
  @last_verification = 0
  message = "#{e.class.name}: #{e.message}: #{sql}"
  log_info(message, name, 0)
  raise ActiveRecord::StatementInvalid, message
end
log_info(sql, name, runtime)
# File rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 131
def log_info(sql, name, runtime)
  return unless @logger

  @logger.debug(
    format_log_entry(
      "#{name.nil? ? "SQL" : name} (#{sprintf("%f", runtime)})",
      sql.gsub(%r +/, " ")
    )
  )
end