@@ -91,10 +91,9 @@ def extensions
91
91
end
92
92
93
93
def get_oid_type ( oid , fmod , column_name , sql_type = '' ) # :nodoc:
94
- # This is unhappy with oid of regproc
95
- #if !type_map.key?(oid)
96
- # load_additional_types([oid])
97
- #end
94
+ if !type_map . key? ( oid )
95
+ load_additional_types ( [ oid ] )
96
+ end
98
97
99
98
type_map . fetch ( oid , fmod , sql_type ) {
100
99
warn "unknown OID #{ oid } : failed to recognize type of '#{ column_name } '. It will be treated as String."
@@ -146,7 +145,9 @@ def initialize_type_map_inner(m)
146
145
m . register_type "path" , OID ::SpecializedString . new ( :path )
147
146
m . register_type "polygon" , OID ::SpecializedString . new ( :polygon )
148
147
m . register_type "circle" , OID ::SpecializedString . new ( :circle )
149
-
148
+ m . register_type "regproc" , OID ::Enum . new
149
+ # FIXME: adding this vector type leads to quoting not handlign Array data in quoting.
150
+ #m.register_type "_int4", OID::Vector.new(",", m.lookup("int4"))
150
151
register_class_with_precision m , "time" , Type ::Time
151
152
register_class_with_precision m , "timestamp" , OID ::Timestamp
152
153
register_class_with_precision m , "timestamptz" , OID ::TimestampWithTimeZone
@@ -206,6 +207,7 @@ def load_additional_types(oids = nil) # :nodoc:
206
207
initializer = ArjdbcTypeMapInitializer . new ( type_map )
207
208
load_types_queries ( initializer , oids ) do |query |
208
209
execute_and_clear ( query , "SCHEMA" , [ ] ) do |records |
210
+ #puts "RECORDS: #{records.to_a}"
209
211
initializer . run ( records )
210
212
end
211
213
end
@@ -218,7 +220,14 @@ def load_types_queries(initializer, oids)
218
220
LEFT JOIN pg_range as r ON oid = rngtypid
219
221
SQL
220
222
if oids
221
- yield query + "WHERE t.oid IN (%s)" % oids . join ( ", " )
223
+ if oids . all? { |e | e . kind_of? Numeric }
224
+ yield query + "WHERE t.oid IN (%s)" % oids . join ( ", " )
225
+ else
226
+ in_list = oids . map { |e | %Q{'#{ e } '} } . join ( ", " )
227
+ #puts caller[0..40]
228
+ puts "IN_LIST = #{ in_list } "
229
+ yield query + "WHERE t.typname IN (%s)" % in_list
230
+ end
222
231
else
223
232
yield query + initializer . query_conditions_for_known_type_names
224
233
yield query + initializer . query_conditions_for_known_type_types
0 commit comments