method
connect
v2.2.1 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
connect()private
Connects to a PostgreSQL server and sets up the adapter depending on the connected server’s characteristics.
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 936
def connect
@connection = PGconn.connect(*@connection_parameters)
PGconn.translate_results = false if PGconn.respond_to?(:translate_results=)
# Ignore async_exec and async_query when using postgres-pr.
@async = @config[:allow_concurrency] && @connection.respond_to?(:async_exec)
# Use escape string syntax if available. We cannot do this lazily when encountering
# the first string, because that could then break any transactions in progress.
# See: http://www.postgresql.org/docs/current/static/runtime-config-compatible.html
# If PostgreSQL doesn't know the standard_conforming_strings parameter then it doesn't
# support escape string syntax. Don't override the inherited quoted_string_prefix.
if supports_standard_conforming_strings?
self.class.instance_eval do
define_method(:quoted_string_prefix) { 'E' }
end
end
# Money type has a fixed precision of 10 in PostgreSQL 8.2 and below, and as of
# PostgreSQL 8.3 it has a fixed precision of 19. PostgreSQLColumn.extract_precision
# should know about this but can't detect it there, so deal with it here.
money_precision = (postgresql_version >= 80300) ? 19 : 10
PostgreSQLColumn.module_eval("def extract_precision(sql_type)\nif sql_type =~ /^money$/\n\#{money_precision}\nelse\nsuper\nend\nend\n")
configure_connection
end Related methods
- Instance methods
- active?
- adapter_name
- add_column
- add_order_by_for_association_limiting!
- begin_db_transaction
- change_column
- change_column_default
- change_column_null
- client_min_messages
- client_min_messages=
- columns
- commit_db_transaction
- create_database
- current_database
- default_sequence_name
- disable_referential_integrity
- disconnect!
- distinct
- drop_database
- encoding
- escape_bytea
- execute
- indexes
- insert
- native_database_types
- pk_and_sequence_for
- query
- quote
- quote_column_name
- quote_string
- quoted_date
- reconnect!
- recreate_database
- remove_index
- rename_column
- rename_table
- reset_pk_sequence!
- result_as_array
- rollback_db_transaction
- schema_search_path
- schema_search_path=
- select_rows
- supports_ddl_transactions?
- supports_disable_referential_integrity?
- supports_insert_with_returning?
- supports_migrations?
- supports_standard_conforming_strings?
- table_alias_length
- tables
- transaction
- transaction_active?
- type_to_sql
- unescape_bytea
- update_sql
- Class methods
- new
- Protected methods
-
postgresql_version - Private methods
-
column_definitions -
configure_connection -
connect -
last_insert_id -
select -
select_raw