Module: Sequel::Postgres

Defined in:
lib/sequel/lib/sequel/adapters/postgres.rb

Defined Under Namespace

Classes: Adapter, Database, Dataset

Constant Summary collapse

PG_TYPES =

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

{}
PG_TYPE_PROCS =

Use a single proc for each type to conserve memory

{
  [16] =>  lambda{|s| s == 't'}, # boolean
  [17] => lambda{|s| ::Sequel::SQL::Blob.new(Adapter.unescape_bytea(s))}, # bytea
  [20, 21, 22, 23, 26] => lambda{|s| s.to_i}, # integer
  [700, 701] => lambda{|s| s.to_f}, # float
  [790, 1700] => lambda{|s| BigDecimal.new(s)}, # numeric
  [1082] => lambda{|s| @use_iso_date_format ? Date.new(*s.split("-").map{|x| x.to_i}) : Sequel.string_to_date(s)}, # date
  [1083, 1266] => lambda{|s| Sequel.string_to_time(s)}, # time
  [1114, 1184] => lambda{|s| Sequel.database_to_application_timestamp(s)}, # timestamp
}

Class Attribute Summary collapse

Class Attribute Details

.use_iso_date_formatObject

As an optimization, Sequel sets the date style to ISO, so that PostgreSQL provides the date in a known format that Sequel can parse faster. This can be turned off if you require a date style other than ISO.


114
115
116
# File 'lib/sequel/lib/sequel/adapters/postgres.rb', line 114

def use_iso_date_format
  @use_iso_date_format
end