|
1 | 1 | # frozen_string_literal: true
|
2 |
| - |
3 | 2 | require 'thread'
|
4 | 3 |
|
5 | 4 | module ArJdbc
|
@@ -91,8 +90,23 @@ def extensions
|
91 | 90 | end
|
92 | 91 |
|
93 | 92 | def get_oid_type(oid, fmod, column_name, sql_type = '') # :nodoc:
|
94 |
| - if !type_map.key?(oid) |
95 |
| - load_additional_types([oid]) |
| 93 | + # Note: type_map is storing a bunch of oid type prefixed with a namespace even |
| 94 | + # if they are not namespaced (e.g. ""."oidvector"). builtin types which are |
| 95 | + # common seem to not be prefixed (e.g. "varchar"). OID numbers are also keys |
| 96 | + # but JDBC never returns those. So the current scheme is to check with |
| 97 | + # what we got and that covers number and plain strings and otherwise we will |
| 98 | + # wrap with the namespace form. |
| 99 | + found = type_map.key?(oid) |
| 100 | + |
| 101 | + if !found |
| 102 | + key = oid.kind_of?(String) && oid != "oid" ? "\"\".\"#{oid}\"" : oid |
| 103 | + found = type_map.key?(key) |
| 104 | + |
| 105 | + if !found |
| 106 | + load_additional_types([oid]) |
| 107 | + else |
| 108 | + oid = key |
| 109 | + end |
96 | 110 | end
|
97 | 111 |
|
98 | 112 | type_map.fetch(oid, fmod, sql_type) {
|
@@ -207,7 +221,6 @@ def load_additional_types(oids = nil) # :nodoc:
|
207 | 221 | initializer = ArjdbcTypeMapInitializer.new(type_map)
|
208 | 222 | load_types_queries(initializer, oids) do |query|
|
209 | 223 | execute_and_clear(query, "SCHEMA", []) do |records|
|
210 |
| - #puts "RECORDS: #{records.to_a}" |
211 | 224 | initializer.run(records)
|
212 | 225 | end
|
213 | 226 | end
|
|
0 commit comments