Class: ActiveRecord::ConnectionAdapters::SnowflakeOdbcAdapter

Inherits:
AbstractAdapter
  • Object
show all
Includes:
ActiveRecord::ConnectionAdapters::SnowflakeOdbc::DatabaseStatements, ActiveRecord::ConnectionAdapters::SnowflakeOdbc::Quoting, ActiveRecord::ConnectionAdapters::SnowflakeOdbc::SchemaStatements
Defined in:
lib/active_record/connection_adapters/snowflake_odbc_adapter.rb

Constant Summary collapse

ADAPTER_NAME =
"ODBC"
TYPE_MAP =
Type::TypeMap.new.tap { |m| initialize_type_map(m) }

Constants included from ActiveRecord::ConnectionAdapters::SnowflakeOdbc::SchemaStatements

ActiveRecord::ConnectionAdapters::SnowflakeOdbc::SchemaStatements::SQL_NO_NULLS, ActiveRecord::ConnectionAdapters::SnowflakeOdbc::SchemaStatements::SQL_NULLABLE, ActiveRecord::ConnectionAdapters::SnowflakeOdbc::SchemaStatements::SQL_NULLABLE_UNKNOWN

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveRecord::ConnectionAdapters::SnowflakeOdbc::SchemaStatements

#column_definitions, #data_sources, #native_database_types, #new_column_from_field, #primary_key, #rename_column, #rename_table, #table_exists?, #tables, #views

Methods included from ActiveRecord::ConnectionAdapters::SnowflakeOdbc::DatabaseStatements

#begin_db_transaction, #bind_params, #commit_db_transaction, #exec_delete, #exec_rollback_db_transaction, #execute, #internal_exec_query, #prepared_binds, #prepared_statements

Constructor Details

#initializeSnowflakeOdbcAdapter

Returns a new instance of SnowflakeOdbcAdapter.



107
108
109
110
111
112
# File 'lib/active_record/connection_adapters/snowflake_odbc_adapter.rb', line 107

def initialize(...)
  super
  @raw_connection, @config = self.class.new_client(@config)
  @raw_connection.use_time = true
  ::SnowflakeOdbcAdapter::Metadata.instance.connection(@config, @raw_connection)
end

Class Method Details

.dbconsole(config, options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/active_record/connection_adapters/snowflake_odbc_adapter.rb', line 38

def dbconsole(config, options = {})
  raise NotImplementedError
end

.new_client(config) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/active_record/connection_adapters/snowflake_odbc_adapter.rb', line 24

def new_client(config)
  config = config.symbolize_keys
  _, config = if config.key?(:dsn)
    dsn_connection(config)
  elsif config.key?(:conn_str)
    str_connection(config)
  else
    raise ArgumentError, "No data source name (:dsn) or connection string (:conn_str) specified."
  end
rescue ::ODBC::Error => error
  # TODO: be more specific on error to raise
  raise ActiveRecord::ConnectionNotEstablished, error.message
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/active_record/connection_adapters/snowflake_odbc_adapter.rb', line 118

def active?
  @raw_connection.connected?
end

#disconnect!Object



126
127
128
# File 'lib/active_record/connection_adapters/snowflake_odbc_adapter.rb', line 126

def disconnect!
  @raw_connection.disconnect if @raw_connection.connected?
end

#reconnectObject



122
123
124
# File 'lib/active_record/connection_adapters/snowflake_odbc_adapter.rb', line 122

def reconnect
  @raw_connection, @config = self.class.new_client(@config)
end

#supports_insert_returning?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/active_record/connection_adapters/snowflake_odbc_adapter.rb', line 114

def supports_insert_returning?
  false
end