mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
feat(postgres): expose PgTypeKind
This commit is contained in:
parent
f0f93c4f79
commit
08d2c79279
@ -32,7 +32,7 @@ pub use options::{PgConnectOptions, PgSslMode};
|
||||
pub use row::PgRow;
|
||||
pub use statement::PgStatement;
|
||||
pub use transaction::PgTransactionManager;
|
||||
pub use type_info::PgTypeInfo;
|
||||
pub use type_info::{PgTypeInfo, PgTypeKind};
|
||||
pub use value::{PgValue, PgValueFormat, PgValueRef};
|
||||
|
||||
/// An alias for [`Pool`][crate::pool::Pool], specialized for Postgres.
|
||||
|
||||
@ -141,7 +141,6 @@ pub struct PgCustomType {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "offline", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[doc(hidden)]
|
||||
pub enum PgTypeKind {
|
||||
Simple,
|
||||
Pseudo,
|
||||
@ -158,8 +157,8 @@ impl PgTypeInfo {
|
||||
PgType::try_from_oid(oid).map(Self)
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub fn __kind(&self) -> &PgTypeKind {
|
||||
/// Returns the _kind_ (simple, array, enum, etc.) for this type.
|
||||
pub fn kind(&self) -> &PgTypeKind {
|
||||
self.0.kind()
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ async fn it_describes_enum() -> anyhow::Result<()> {
|
||||
assert_eq!(ty.name(), "status");
|
||||
|
||||
assert_eq!(
|
||||
format!("{:?}", ty.__kind()),
|
||||
format!("{:?}", ty.kind()),
|
||||
r#"Enum(["new", "open", "closed"])"#
|
||||
);
|
||||
|
||||
@ -87,7 +87,7 @@ async fn it_describes_composite() -> anyhow::Result<()> {
|
||||
assert_eq!(ty.name(), "inventory_item");
|
||||
|
||||
assert_eq!(
|
||||
format!("{:?}", ty.__kind()),
|
||||
format!("{:?}", ty.kind()),
|
||||
r#"Composite([("name", PgTypeInfo(Text)), ("supplier_id", PgTypeInfo(Int4)), ("price", PgTypeInfo(Int8))])"#
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user