Sha256: 31e6caac64930cc94bea0381efca6c0375a7e7f73f3779e9e074bd92a04fc5a8
Contents?: true
Size: 932 Bytes
Versions: 13
Compression:
Stored size: 932 Bytes
Contents
# frozen_string_literal: true module MiniSql module Postgres module Coders class NumericCoder < PG::SimpleDecoder def decode(string, tuple = nil, field = nil) BigDecimal(string) end end class IPAddrCoder < PG::SimpleDecoder def decode(string, tuple = nil, field = nil) IPAddr.new(string) end end class TimestampUtc < PG::SimpleDecoder # exact same implementation as Rails here ISO_DATETIME = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/ def decode(string, tuple = nil, field = nil) if string =~ ISO_DATETIME microsec = ($7.to_r * 1_000_000).to_i Time.utc $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec else STDERR.puts "unexpected date time format #{string}" string end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems