From f93beb460a3780e437ddc2f7c72a9d685cd5b74c Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sat, 18 Jan 2020 14:04:17 +0100 Subject: [PATCH] Add PgTypeInfo::with_oid --- sqlx-core/src/postgres/types/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sqlx-core/src/postgres/types/mod.rs b/sqlx-core/src/postgres/types/mod.rs index faabbe1531..28404d8b26 100644 --- a/sqlx-core/src/postgres/types/mod.rs +++ b/sqlx-core/src/postgres/types/mod.rs @@ -24,6 +24,14 @@ impl PgTypeInfo { pub(crate) fn new(id: TypeId) -> Self { Self { id } } + + /// Create a `PgTypeInfo` from a type's object identifier. + /// + /// The object identifier of a type can be queried with + /// `SELECT oid FROM pg_type WHERE typname = ;` + pub fn with_oid(oid: u32) -> Self { + Self { id: TypeId(oid) } + } } impl Display for PgTypeInfo {