|
From: Michael N. <mne...@us...> - 2002-07-26 17:56:47
|
Update of /cvsroot/ruby-dbi/src/lib/dbd_pg
In directory usw-pr-cvs1:/tmp/cvs-serv1796
Modified Files:
Pg.rb
Log Message:
enhanced conversion: default is to_str, added timestamp (with/without timezone)
Index: Pg.rb
===================================================================
RCS file: /cvsroot/ruby-dbi/src/lib/dbd_pg/Pg.rb,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Pg.rb 3 Jul 2002 19:56:10 -0000 1.22
+++ Pg.rb 26 Jul 2002 17:56:43 -0000 1.23
@@ -285,8 +285,8 @@
def convert(obj,typeid)
return nil if obj.nil?
- converter = @type_map[typeid]
- raise DBI::InterfaceError, "Unsupported Type (typeid=#{typeid})" if converter.nil?
+ converter = @type_map[typeid] || :as_str
+ #raise DBI::InterfaceError, "Unsupported Type (typeid=#{typeid})" if converter.nil?
@coerce.coerce(converter, obj)
end
@@ -320,16 +320,20 @@
res.result.each { |name, idstr|
@type_map[idstr.to_i] =
case name
- when '_bool' then :as_bool
- when '_int8', '_int4', '_int2' then :as_int
- when '_varchar' then :as_str
- when '_float4','_float8' then :as_float
- when '_timestamp' then :as_timestamp
- when '_date' then :as_date
- when '_bytea' then :as_bytea
- else :as_str
+ when '_bool' then :as_bool
+ when '_int8', '_int4', '_int2' then :as_int
+ when '_varchar' then :as_str
+ when '_float4','_float8' then :as_float
+ when '_timestamp', '_timestamptz' then :as_timestamp
+ when '_date' then :as_date
+ when '_bytea' then :as_bytea
+ else :as_str
end
}
+
+ # additional conversions
+ @type_map[705] ||= :as_str # select 'hallo'
+ @type_map[1114] ||= :as_timestamp # TIMESTAMP WITHOUT TIME ZONE
end
|