Class: MiniSql::ActiveRecordPostgres::Connection

Inherits:
Postgres::Connection show all
Defined in:
lib/mini_sql/active_record_postgres/connection.rb

Instance Attribute Summary collapse

Attributes inherited from Postgres::Connection

#deserializer_cache, #param_encoder, #type_map

Instance Method Summary collapse

Methods inherited from Postgres::Connection

default_deserializer_cache, #escape_string, #exec, #prepared, #query, #query_array, #query_decorator, #query_hash, #query_single, type_map, typemap

Methods inherited from Connection

#build, #escape_string, #exec, get, #query, #query_decorator, #query_hash, #query_single, #to_sql

Constructor Details

#initialize(active_record_adapter, args = nil) ⇒ Connection

Initialize a new MiniSql::Postgres::Connection object

Parameters:

  • active_record_adapter (ActiveRecord::ConnectionAdapters::PostgresqlAdapter)
  • deserializer_cache (MiniSql::DeserializerCache)

    a cache of field names to deserializer, can be nil

  • type_map (PG::TypeMap)

    a type mapper for all results returned, can be nil



13
14
15
16
# File 'lib/mini_sql/active_record_postgres/connection.rb', line 13

def initialize(active_record_adapter, args = nil)
  @active_record_connection = active_record_adapter
  super(nil, args)
end

Instance Attribute Details

#active_record_connectionObject (readonly)

Returns the value of attribute active_record_connection.



6
7
8
# File 'lib/mini_sql/active_record_postgres/connection.rb', line 6

def active_record_connection
  @active_record_connection
end

Instance Method Details

#query_each(sql, *params) ⇒ Object

These two methods do not use ‘run`, so we need to apply the lock separately:



24
25
26
# File 'lib/mini_sql/active_record_postgres/connection.rb', line 24

def query_each(sql, *params)
  with_lock { super }
end

#query_each_hash(sql, *params) ⇒ Object



27
28
29
# File 'lib/mini_sql/active_record_postgres/connection.rb', line 27

def query_each_hash(sql, *params)
  with_lock { super }
end

#raw_connectionObject



18
19
20
# File 'lib/mini_sql/active_record_postgres/connection.rb', line 18

def raw_connection
  active_record_connection.raw_connection
end