Class: MiniSql::Postgres::PreparedConnection

Inherits:
Connection show all
Defined in:
lib/mini_sql/postgres/prepared_connection.rb

Instance Attribute Summary collapse

Attributes inherited from Connection

#param_encoder, #raw_connection, #type_map

Instance Method Summary collapse

Methods inherited from Connection

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

Methods inherited from Connection

#escape_string, #exec, get, #query, #query_decorator, #query_each, #query_each_hash, #query_hash, #query_single, #to_sql

Constructor Details

#initialize(unprepared_connection) ⇒ PreparedConnection

Returns a new instance of PreparedConnection.



9
10
11
12
13
14
15
16
17
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 9

def initialize(unprepared_connection)
  @unprepared         = unprepared_connection
  @raw_connection     = unprepared_connection.raw_connection
  @type_map           = unprepared_connection.type_map
  @param_encoder      = unprepared_connection.param_encoder

  @prepared_cache     = PreparedCache.new(@raw_connection)
  @param_binder       = PreparedBinds.new
end

Instance Attribute Details

#unpreparedObject (readonly)

Returns the value of attribute unprepared.



7
8
9
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 7

def unprepared
  @unprepared
end

Instance Method Details

#build(_) ⇒ Object



19
20
21
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 19

def build(_)
  raise 'Builder can not be called on prepared connections, instead of `::MINI_SQL.prepared.build(sql).query` use `::MINI_SQL.build(sql).prepared.query`'
end

#deserializer_cacheObject



27
28
29
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 27

def deserializer_cache
  @unprepared.deserializer_cache
end

#prepared(condition = true) ⇒ Object



23
24
25
# File 'lib/mini_sql/postgres/prepared_connection.rb', line 23

def prepared(condition = true)
  condition ? self : @unprepared
end