Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

Inherits:
AbstractAdapter
  • Object
show all
Includes:
Jdbc::ConnectionPoolCallbacks, ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting, ActiveRecord::ConnectionAdapters::PostgreSQL::ReferentialIntegrity, ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements, ArJdbc::Abstract::ConnectionManagement, ArJdbc::Abstract::Core, ArJdbc::Abstract::DatabaseStatements, ArJdbc::Abstract::StatementCache, ArJdbc::Abstract::TransactionSupport, ArJdbc::PostgreSQL, ArJdbc::Util::QuotedCache
Defined in:
lib/arjdbc/postgresql/adapter.rb

Constant Summary collapse

OID =

AR expects OID to be available on the adapter

ActiveRecord::ConnectionAdapters::PostgreSQL::OID
ColumnMethods =
ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnMethods
TableDefinition =
ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
Table =
ActiveRecord::ConnectionAdapters::PostgreSQL::Table

Constants included from ArJdbc::PostgreSQL

ArJdbc::PostgreSQL::ADAPTER_NAME, ArJdbc::PostgreSQL::NATIVE_DATABASE_TYPES

Constants included from ArJdbc::Abstract::DatabaseStatements

ArJdbc::Abstract::DatabaseStatements::NO_BINDS

Instance Attribute Summary

Attributes included from ArJdbc::Abstract::Core

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ArJdbc::Util::QuotedCache

#quote_column_name, #quote_table_name

Methods included from ArJdbc::PostgreSQL

#adapter_name, #add_order_by_for_association_limiting!, #all_schemas, #build_insert_sql, #build_truncate_statements, #check_version, #clear_cache!, #client_min_messages, #client_min_messages=, #configure_connection, #default_index_type?, #default_sequence_name, #disable_extension, #enable_extension, #escape_bytea, #exec_insert, #execute_batch, #explain, #extension_available?, #extension_enabled?, #extensions, #get_advisory_lock, #get_database_version, #index_algorithms, #jdbc_column_class, jdbc_connection_class, #last_insert_id_result, #max_identifier_length, #native_database_types, #quote_table_name, #release_advisory_lock, #remove_column, #reset!, #session_auth=, #set_client_encoding, #set_standard_conforming_strings, #supports_advisory_locks?, #supports_bulk_alter?, #supports_comments?, #supports_common_table_expressions?, #supports_datetime_with_precision?, #supports_ddl_transactions?, #supports_explain?, #supports_expression_index?, #supports_extensions?, #supports_foreign_keys?, #supports_foreign_tables?, #supports_index_sort_order?, #supports_insert_on_conflict?, #supports_insert_returning?, #supports_json?, #supports_lazy_transactions?, #supports_materialized_views?, #supports_optimizer_hints?, #supports_partial_index?, #supports_pgcrypto_uuid?, #supports_ranges?, #supports_savepoints?, #supports_transaction_isolation?, #supports_validate_constraints?, #supports_views?, #truncate, #use_insert_returning?, #valid_type?, #write_query?

Methods included from ArJdbc::Abstract::TransactionSupport

#begin_db_transaction, #begin_isolated_db_transaction, #commit_db_transaction, #create_savepoint, #exec_rollback_db_transaction, #exec_rollback_to_savepoint, #release_savepoint, #supports_savepoints?, #supports_transaction_isolation?

Methods included from ArJdbc::Abstract::StatementCache

#clear_cache!, #delete_cached_statement, #fetch_cached_statement

Methods included from ArJdbc::Abstract::DatabaseStatements

#exec_insert, #exec_query, #exec_update, #execute, #select_all

Methods included from ArJdbc::Abstract::ConnectionManagement

#active?, #disconnect!, #really_valid?, #reconnect!

Methods included from ArJdbc::Abstract::Core

#extract_raw_bind_values, #jdbc_connection, #log, #translate_exception, #translate_exception_class

Methods included from Jdbc::ConnectionPoolCallbacks

#on_checkin, #on_checkout

Constructor Details

#initialize(connection, logger = nil, connection_parameters = nil, config = {}) ⇒ PostgreSQLAdapter

Returns a new instance of PostgreSQLAdapter.



688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/arjdbc/postgresql/adapter.rb', line 688

def initialize(connection, logger = nil, connection_parameters = nil, config = {})
  # @local_tz is initialized as nil to avoid warnings when connect tries to use it
  @local_tz = nil
  @max_identifier_length = nil

  super(connection, logger, config) # configure_connection happens in super

  @type_map = Type::HashLookupTypeMap.new
  initialize_type_map

  @use_insert_returning = @config.key?(:insert_returning) ?
    self.class.type_cast_config_to_boolean(@config[:insert_returning]) : true
end

Class Method Details

.database_exists?(config) ⇒ Boolean

Returns:

  • (Boolean)


702
703
704
705
706
707
708
709
# File 'lib/arjdbc/postgresql/adapter.rb', line 702

def self.database_exists?(config)
  conn = ActiveRecord::Base.postgresql_connection(config)
  conn && conn.really_valid?
rescue ActiveRecord::NoDatabaseError
  false
ensure
  conn.disconnect! if conn
end

Instance Method Details

#jdbc_connection_class(spec) ⇒ Object



720
721
722
# File 'lib/arjdbc/postgresql/adapter.rb', line 720

def jdbc_connection_class(spec)
  ::ArJdbc::PostgreSQL.jdbc_connection_class
end