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

Constants

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

Public Class methods

Public Instance methods

Is this connection alive and ready for queries?

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.

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")

Find a table‘s primary key and sequence.

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

Close then reopen the connection.

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

[Validate]