Module: Sequel::Postgres

Defined in:
lib/sequel_core/adapters/postgres.rb,
lib/sequel_core/adapters/shared/postgres.rb

Overview

Top level module for holding all PostgreSQL-related modules and classes for Sequel.

Defined Under Namespace

Modules: AdapterMethods, DatabaseMethods, DatasetMethods Classes: Adapter, Database, Dataset

Constant Summary collapse

PG_TYPES =

Hash with integer keys and proc values for converting PostgreSQL types.

{
  16 => lambda{ |s| Postgres.string_to_bool(s) }, # boolean
  17 => lambda{ |s| Adapter.unescape_bytea(s).to_blob }, # bytea
  20 => lambda{ |s| s.to_i }, # int8
  21 => lambda{ |s| s.to_i }, # int2
  22 => lambda{ |s| s.to_i }, # int2vector
  23 => lambda{ |s| s.to_i }, # int4
  26 => lambda{ |s| s.to_i }, # oid
  700 => lambda{ |s| s.to_f }, # float4
  701 => lambda{ |s| s.to_f }, # float8
  790 => lambda{ |s| s.to_d }, # money
  1082 => lambda{ |s| s.to_date }, # date
  1083 => lambda{ |s| s.to_time }, # time without time zone
  1114 => lambda{ |s| s.to_sequel_time }, # timestamp without time zone
  1184 => lambda{ |s| s.to_sequel_time }, # timestamp with time zone
  1186 => lambda{ |s| s.to_i }, # interval
  1266 => lambda{ |s| s.to_time }, # time with time zone
  1700 => lambda{ |s| s.to_d }, # numeric
}
CONVERTED_EXCEPTIONS =

Array of exceptions that need to be converted. JDBC uses NativeExceptions, the native adapter uses PGError.

[]

Class Method Summary collapse

Class Method Details

.string_to_bool(s) ⇒ Object

Module method for converting a PostgreSQL string to a boolean value.



106
107
108
109
110
111
112
113
114
# File 'lib/sequel_core/adapters/postgres.rb', line 106

def self.string_to_bool(s)
  if(s.blank?)
    nil
  elsif(s.downcase == 't' || s.downcase == 'true')
    true
  else
    false
  end
end