Skip to content

Commit ab8471e

Browse files
committed
Fix sql_type_from_oid to not to raise unnecessarily and return None on failure
The real fix is, of course, to make sure that oid_to_name never fails for valid oids.
1 parent ab728dc commit ab8471e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

postgresql/driver/pq3.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ def sql_type_from_oid(self, oid, qi = quote_ident):
207207
if oid in self.typinfo:
208208
nsp, name, *_ = self.typinfo[oid]
209209
return qi(nsp) + '.' + qi(name)
210-
return 'pg_catalog.' + pg_types.oid_to_name.get(oid)
210+
name = pg_types.oid_to_name.get(oid)
211+
if name:
212+
return 'pg_catalog.%s' % name
213+
else:
214+
return None
211215

212216
def type_from_oid(self, oid):
213217
if oid in self._cache:

0 commit comments

Comments
 (0)