Skip to content

Commit

Permalink
fix: time macro import issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-mccarthy committed Nov 3, 2021
1 parent 29eb91c commit 005d922
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions sqlx-core/src/lib.rs
Expand Up @@ -104,3 +104,7 @@ pub mod mssql;
/// sqlx uses ahash for increased performance, at the cost of reduced DoS resistance.
use ahash::AHashMap as HashMap;
//type HashMap<K, V> = std::collections::HashMap<K, V, ahash::RandomState>;

#[macro_use]
#[cfg(feature = "time-03")]
extern crate time_03 as time;
4 changes: 2 additions & 2 deletions sqlx-core/src/postgres/types/time_02/datetime.rs
Expand Up @@ -6,7 +6,7 @@ use crate::postgres::{PgArgumentBuffer, PgTypeInfo, PgValueFormat, PgValueRef, P
use crate::types::Type;
use std::borrow::Cow;
use std::mem;
use time_02::{offset, Duration, OffsetDateTime, PrimitiveDateTime};
use time_02::{UtcOffset, Duration, OffsetDateTime, PrimitiveDateTime};

impl Type<Postgres> for PrimitiveDateTime {
fn type_info() -> PgTypeInfo {
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<'r> Decode<'r, Postgres> for PrimitiveDateTime {

impl Encode<'_, Postgres> for OffsetDateTime {
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull {
let utc = self.to_offset(offset!(UTC));
let utc = self.to_offset(UtcOffset::UTC);
let primitive = PrimitiveDateTime::new(utc.date(), utc.time());

Encode::<Postgres>::encode(&primitive, buf)
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/postgres/types/time_02/mod.rs
Expand Up @@ -3,4 +3,4 @@ mod datetime;
mod time;

#[rustfmt::skip]
const PG_EPOCH: ::time_02::Date = ::time_02::date!(2000-1-1);
const PG_EPOCH: time_02::Date = time_02::internals::Date::from_yo_unchecked(2000, 1);

0 comments on commit 005d922

Please sign in to comment.