Skip to content

Commit

Permalink
Update id types
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Dec 12, 2023
1 parent eb3f595 commit bbc0414
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
5 changes: 2 additions & 3 deletions tokio-postgres/src/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use log::debug;
use postgres_protocol::message::backend::Message;
use postgres_protocol::message::frontend;
use std::future::Future;
use std::num::{NonZeroI16, NonZeroU32};
use std::pin::Pin;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
Expand Down Expand Up @@ -98,8 +97,8 @@ pub async fn prepare(
let type_ = get_type(client, field.type_oid()).await?;
let column = Column {
name: field.name().to_string(),
table_oid: NonZeroU32::new(field.table_oid()),
column_id: NonZeroI16::new(field.column_id()),
table_oid: Some(field.table_oid()).filter(|n| *n != 0),
column_id: Some(field.column_id()).filter(|n| *n != 0),
r#type: type_,
};
columns.push(column);
Expand Down
13 changes: 5 additions & 8 deletions tokio-postgres/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use crate::codec::FrontendMessage;
use crate::connection::RequestMessages;
use crate::types::Type;
use postgres_protocol::message::frontend;
use std::{
num::{NonZeroI16, NonZeroU32},
sync::{Arc, Weak},
};
use std::sync::{Arc, Weak};

struct StatementInner {
client: Weak<InnerClient>,
Expand Down Expand Up @@ -68,8 +65,8 @@ impl Statement {
#[derive(Debug)]
pub struct Column {
pub(crate) name: String,
pub(crate) table_oid: Option<NonZeroU32>,
pub(crate) column_id: Option<NonZeroI16>,
pub(crate) table_oid: Option<u32>,
pub(crate) column_id: Option<i16>,
pub(crate) r#type: Type,
}

Expand All @@ -80,12 +77,12 @@ impl Column {
}

/// Returns the OID of the underlying database table.
pub fn table_oid(&self) -> Option<NonZeroU32> {
pub fn table_oid(&self) -> Option<u32> {
self.table_oid
}

/// Return the column ID within the underlying database table.
pub fn column_id(&self) -> Option<NonZeroI16> {
pub fn column_id(&self) -> Option<i16> {
self.column_id
}

Expand Down

0 comments on commit bbc0414

Please sign in to comment.