Class: ActiveRecord::ConnectionAdapters::ODBCAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::ODBCAdapter
- Includes:
- ODBCAdapter::DatabaseLimits, ODBCAdapter::DatabaseStatements, ODBCAdapter::Quoting, ODBCAdapter::SchemaStatements
- Defined in:
- lib/active_record/connection_adapters/odbc_adapter.rb
Direct Known Subclasses
ODBCAdapter::Adapters::MySQLODBCAdapter, ODBCAdapter::Adapters::PostgreSQLODBCAdapter
Constant Summary collapse
- ADAPTER_NAME =
'ODBC'.freeze
- BOOLEAN_TYPE =
'BOOLEAN'.freeze
- ERR_DUPLICATE_KEY_VALUE =
23505
Constants included from ODBCAdapter::DatabaseStatements
ODBCAdapter::DatabaseStatements::SQL_NO_NULLS, ODBCAdapter::DatabaseStatements::SQL_NULLABLE, ODBCAdapter::DatabaseStatements::SQL_NULLABLE_UNKNOWN
Instance Attribute Summary collapse
-
#dbms ⇒ Object
readonly
Returns the value of attribute dbms.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Checks whether the connection to the database is still active.
-
#adapter_name ⇒ Object
Returns the human-readable name of the adapter.
-
#disconnect! ⇒ Object
Disconnects from the database if already connected.
-
#initialize(connection, logger, dbms) ⇒ ODBCAdapter
constructor
A new instance of ODBCAdapter.
-
#reconnect! ⇒ Object
(also: #reset!)
Disconnects from the database if already connected, and establishes a new connection with the database.
-
#supports_migrations? ⇒ Boolean
Does this adapter support migrations? Backend specific, as the abstract adapter always returns
false.
Methods included from ODBCAdapter::SchemaStatements
#columns, #current_database, #index_name, #indexes, #native_database_types, #primary_key, #tables
Methods included from ODBCAdapter::Quoting
#quote_column_name, #quote_string, #quoted_date
Methods included from ODBCAdapter::DatabaseStatements
#begin_db_transaction, #commit_db_transaction, #default_sequence_name, #exec_delete, #exec_query, #exec_rollback_db_transaction, #execute, #select_rows
Methods included from ODBCAdapter::DatabaseLimits
Constructor Details
#initialize(connection, logger, dbms) ⇒ ODBCAdapter
Returns a new instance of ODBCAdapter.
82 83 84 85 86 87 |
# File 'lib/active_record/connection_adapters/odbc_adapter.rb', line 82 def initialize(connection, logger, dbms) super(connection, logger) @connection = connection @dbms = dbms @visitor = self.class::BindSubstitution.new(self) end |
Instance Attribute Details
#dbms ⇒ Object (readonly)
Returns the value of attribute dbms.
80 81 82 |
# File 'lib/active_record/connection_adapters/odbc_adapter.rb', line 80 def dbms @dbms end |
Instance Method Details
#active? ⇒ Boolean
Checks whether the connection to the database is still active. This includes checking whether the database is actually capable of responding, i.e. whether the connection isn’t stale.
106 107 108 |
# File 'lib/active_record/connection_adapters/odbc_adapter.rb', line 106 def active? @connection.connected? end |
#adapter_name ⇒ Object
Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.
91 92 93 |
# File 'lib/active_record/connection_adapters/odbc_adapter.rb', line 91 def adapter_name ADAPTER_NAME end |
#disconnect! ⇒ Object
Disconnects from the database if already connected. Otherwise, this method does nothing.
126 127 128 |
# File 'lib/active_record/connection_adapters/odbc_adapter.rb', line 126 def disconnect! @connection.disconnect if @connection.connected? end |
#reconnect! ⇒ Object Also known as: reset!
Disconnects from the database if already connected, and establishes a new connection with the database.
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/active_record/connection_adapters/odbc_adapter.rb', line 112 def reconnect! disconnect! @connection = if .key?(:dsn) ODBC.connect([:dsn], [:username], [:password]) else ODBC::Database.new.drvconnect([:driver]) end super end |
#supports_migrations? ⇒ Boolean
Does this adapter support migrations? Backend specific, as the abstract adapter always returns false.
97 98 99 |
# File 'lib/active_record/connection_adapters/odbc_adapter.rb', line 97 def supports_migrations? true end |