Module: Sequel::ActiveRecordConnection::Postgres

Defined in:
lib/sequel/extensions/activerecord_connection/postgres.rb

Defined Under Namespace

Modules: ConnectionMethods

Instance Method Summary collapse

Instance Method Details

#synchronizeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sequel/extensions/activerecord_connection/postgres.rb', line 6

def synchronize(*)
  super do |conn|
    conn.extend(ConnectionMethods)
    conn.instance_variable_set(:@db, self)

    Utils.add_prepared_statements_cache(conn)

    # compatibility for pg_streaming database extension from sequel_pg gem
    if defined?(Sequel::Postgres::Streaming) && is_a?(Sequel::Postgres::Streaming)
      conn.extend(Sequel::Postgres::Streaming::AdapterMethods)
    end

    yield conn
  end
end

#transaction(opts = OPTS) ⇒ Object

Reject unsupported Postgres-specific transaction options.



23
24
25
26
27
28
29
30
31
32
# File 'lib/sequel/extensions/activerecord_connection/postgres.rb', line 23

def transaction(opts = OPTS)
  %i[deferrable read_only synchronous].each do |key|
    fail Error, "#{key.inspect} transaction option is currently not supported" if opts.key?(key)
  end

  super
rescue => e
  activerecord_connection.clear_cache! if e.class.name == "ActiveRecord::PreparedStatementCacheExpired" && !in_transaction?
  raise
end