Class | ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
In: | lib/active_record/connection_adapters/postgresql_adapter.rb
Parent: | AbstractAdapter

The PostgreSQL adapter works both with the C-based (www.postgresql.jp/interfaces/ruby/) and the Ruby-base (available both as gem and from rubyforge.org/frs/?group_id=234&release_id=1145) drivers.

Options:

- `:host` — Defaults to localhost
- `:port` — Defaults to 5432
- `:username` — Defaults to nothing
- `:password` — Defaults to nothing
- `:database` — The name of the database. No default, must be provided.
- `:schema_search_path` — An optional schema search path for the connection given as a string of comma-separated schema names. This is backward-compatible with the :schema_order option.
- `:encoding` — An optional client encoding that is using in a SET client_encoding TO <encoding> call on connection.
- `:min_messages` — An optional client min messages that is using in a SET client_min_messages TO <min_messages> call on connection.
- `:allow_concurrency` — If true, use async query methods so Ruby threads don‘t deadlock; otherwise, use blocking query methods.

### Methods

active? adapter_name add_column add_order_by_for_association_limiting! default_sequence_name disconnect! distinct native_database_types new pk_and_sequence_for quote quote_column_name quoted_date reconnect! rename_table reset_pk_sequence! supports_migrations? table_alias_length

### Constants

BYTEA_COLUMN_TYPE_OID | = | 17
NUMERIC_COLUMN_TYPE_OID | = | 1700
TIMESTAMPOID | = | 1114
TIMESTAMPTZOID | = | 1184

### Public Class methods

new(connection, logger, config = {})

### Public Instance methods

active?()

Is this connection alive and ready for queries?

adapter_name()
add_column(table_name, column_name, type, options = {})
add_order_by_for_association_limiting!(sql, options)

ORDER BY clause for the passed order option.

PostgreSQL does not allow arbitrary ordering when using DISTINCT ON, so we work around this by wrapping the sql as a sub-select and ordering in that query.

default_sequence_name(table_name, pk = nil)
disconnect!()
distinct(columns, order_by)

SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause.

PostgreSQL requires the ORDER BY columns in the select list for distinct queries, and requires that the ORDER BY include the distinct column.

      distinct("posts.id", "posts.created_at desc")

native_database_types()
pk_and_sequence_for(table)

Find a table‘s primary key and sequence.

quote(value, column = nil)

QUOTING ==================================================

quote_column_name(name)
quoted_date(value)
reconnect!()

Close then reopen the connection.

rename_table(name, new_name)
reset_pk_sequence!(table, pk = nil, sequence = nil)

Resets sequence to the max value of the table‘s pk if present.

supports_migrations?()
table_alias_length()

[Validate]