Generic PostgreSQL type OID lookup.
Provides a single-round-trip helper that resolves arbitrary PostgreSQL type names — including extension types like hstore, citext, vector — to their base and array OIDs via to_regtype(). The library does not auto-discover extension OIDs at connect time; callers use this API on demand and pass the OIDs to OID-aware encoders such as toPgBinaryParam(v: PgHstore, oid: int32).
Re-exported through pg_connection.nim.
Types
TypeOidInfo = tuple[oid: int32, arrayOid: int32]
- Result of lookupTypeOids. oid is the base type OID and arrayOid is the corresponding array type OID (pg_type.typarray); arrayOid is 0 for types that have no array companion.
Procs
proc lookupTypeOids(conn: PgConnection; names: seq[string]): Future[ Table[string, TypeOidInfo]] {....stackTrace: false, raises: [Exception, ValueError, PgTypeError, PgConnectionError, CatchableError], tags: [RootEffect, TimeEffect], forbids: [].}
-
Resolve PostgreSQL type names to (oid, arrayOid) tuples in a single round trip via to_regtype(). Resolution honours the connection's current search_path; types not found on the server are omitted from the result, so callers detect absence with hasKey / getOrDefault.
Requires the connection to be in csReady state and raises PgConnectionError otherwise. Rejects names containing characters outside [A-Za-z0-9_."] with PgTypeError. Empty names returns an empty table without contacting the server.
Results are a snapshot — call again after SET search_path or CREATE/DROP EXTENSION.
Example:
let oids = await conn.lookupTypeOids(@["hstore", "citext"]) if oids.hasKey("hstore"): let p = toPgBinaryParam(myHstore, oids["hstore"].oid)