From 07ff5bf5946f5e205e9236d18e4e42ebffa18753 Mon Sep 17 00:00:00 2001 From: piperRyan Date: Wed, 23 Feb 2022 00:19:33 -0500 Subject: [PATCH] fix: resolve issue when integration with postgres --- Cargo.toml | 3 ++- src/integrations/rust_postgres.rs | 8 ++++---- src/lib.rs | 7 ------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 60492f6..484e0bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,8 @@ include = ["src/*", "Cargo.toml", "LICENSE", "README.md"] categories = ["date-and-time"] [features] -default = ["postgres-types"] +default = ["postgres"] +postgres = ["postgres-types"] [dependencies] chrono = { version = "^0.4" } diff --git a/src/integrations/rust_postgres.rs b/src/integrations/rust_postgres.rs index e5954d7..9ad0bc5 100644 --- a/src/integrations/rust_postgres.rs +++ b/src/integrations/rust_postgres.rs @@ -1,13 +1,13 @@ use crate::Interval; use bytes::{Buf, BufMut, BytesMut}; +use std::error::Error; use postgres_types::{to_sql_checked, FromSql, IsNull, ToSql, Type}; impl<'a> FromSql<'a> for Interval { fn from_sql(_: &Type, mut raw: &'a [u8]) -> Result> { - let microseconds: i64 = raw.read_i64::()?; - let days: i32 = raw.read_i32::()?; - let months: i32 = raw.read_i32::()?; - + let microseconds = raw.get_i64(); + let days = raw.get_i32(); + let months = raw.get_i32(); Ok(Interval { months, days, diff --git a/src/lib.rs b/src/lib.rs index 986c000..cf52cae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,3 @@ -#[cfg(feature = "postgres")] -#[macro_use] -extern crate postgres; -#[cfg(feature = "postgres")] -extern crate byteorder; -extern crate chrono; - #[cfg(feature = "postgres")] mod integrations;