class BigRecord::ConnectionAdapters::AbstractAdapter
All the concrete database adapters follow the interface laid down in this class. You can use this interface directly by borrowing the database connection from the Base with BigRecord::Base#connection.
Most of the methods in the adapter are useful during migrations. Most notably, SchemaStatements#create_table, SchemaStatements#drop_table, SchemaStatements#add_index, SchemaStatements#remove_index, SchemaStatements#add_column, SchemaStatements#change_column and SchemaStatements#remove_column are very useful.
Public Instance Methods
Is this connection active and ready to perform queries?
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 79 def active? @active != false end
Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 29 def adapter_name 'Abstract' end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 164 def create_table(table_name, column_families) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 150 def delete(table_name, row) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 154 def delete_all(table_name) raise NotImplementedError end
Override to turn off referential integrity while executing +&block+
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 72 def disable_referential_integrity(&block) yield end
Close this connection
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 89 def disconnect! @active = false end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 168 def drop_table(table_name) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 130 def get(table_name, row, column, options={}) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 138 def get_columns(table_name, row, columns, options={}) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 134 def get_columns_raw(table_name, row, columns, options={}) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 146 def get_consecutive_rows(table_name, start_row, limit, columns, stop_row = nil) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 142 def get_consecutive_rows_raw(table_name, start_row, limit, columns, stop_row = nil) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 126 def get_raw(table_name, row, column, options={}) raise NotImplementedError end
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 lib/big_record/connection_adapters/abstract_adapter.rb, line 53 def prefetch_primary_key?(table_name = nil) false end
Override to return the quoted table name if the database needs it
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 65 def quote_table_name(name) name end
Provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 112 def raw_connection @connection end
Close this connection and open a new one in its place.
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 84 def reconnect! @active = true end
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 lib/big_record/connection_adapters/abstract_adapter.rb, line 95 def requires_reloading? false end
Does this adapter support using DISTINCT within COUNT? This is
true
for all adapters except sqlite.
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 41 def supports_count_distinct? false end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 45 def supports_ddl_transactions? false end
Does this adapter support migrations? Backend specific, as the abstract
adapter always returns false
.
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 35 def supports_migrations? false end
SCHEMA STATEMENTS ========================================
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 160 def table_exists?(table_name) raise NotImplementedError end
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 122 def update(table_name, row, values, timestamp) raise NotImplementedError end
DATABASE STATEMENTS ======================================
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 118 def update_raw(table_name, row, values, timestamp) raise NotImplementedError end
Lazily verify this connection, calling active?
only if it
hasn't been called for timeout
seconds.
# File lib/big_record/connection_adapters/abstract_adapter.rb, line 101 def verify!(timeout) now = Time.now.to_i if (now - @last_verification) > timeout reconnect! unless active? @last_verification = now end end