Class: ViewData::PG::Session

Inherits:
MessageStore::Postgres::Session
  • Object
show all
Defined in:
lib/view_data/pg/session.rb

Class Method Summary collapse

Class Method Details

.build(settings: nil) ⇒ Object



8
9
10
11
12
# File 'lib/view_data/pg/session.rb', line 8

def self.build(settings: nil)
  settings ||= Settings.instance

  super(settings: settings)
end

.build_connectionObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/view_data/pg/session.rb', line 14

def self.build_connection(*)
  connection = super

  type_map_for_results = connection.type_map_for_results

  name_decoder = ::PG::TextDecoder::String.new({
    :oid => 19,
    :name => 'name'
  })

  regproc_decoder = ::PG::TextDecoder::String.new({
    :oid => 24,
    :name => 'regproc'
  })

  numeric_decoder = ::PG::TextDecoder::Float.new({
    :oid => 1700,
    :name => 'numeric'
  })

  type_map_for_results.add_coder(name_decoder)
  type_map_for_results.add_coder(regproc_decoder)
  type_map_for_results.add_coder(numeric_decoder)

  type_map_for_queries = ::PG::BasicTypeMapForQueries.new(connection)

  connection.type_map_for_queries = type_map_for_queries

  connection
end