Skip to content

Commit

Permalink
chore: silence some deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Aug 11, 2023
1 parent 419e99f commit a8b91ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ pub fn datetime_iso_string(
sec: Option<u32>,
millis: Option<u32>,
) -> String {
#[allow(deprecated)]
Utc.ymd(year, month, day)
.and_hms_milli(or_zero(hour), or_zero(min), or_zero(sec), or_zero(millis))
.to_rfc3339()
}

/// Convenience date string (UTC, RFC 3339) constructor so you don't have to remember the format.
pub fn date_iso_string(year: i32, month: u32, day: u32) -> String {
#[allow(deprecated)]
Utc.ymd(year, month, day).and_hms_milli(0, 0, 0, 0).to_rfc3339()
}

Expand Down
4 changes: 3 additions & 1 deletion query-engine/connectors/mongodb-query-connector/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ fn read_scalar_value(bson: Bson, meta: &ScalarOutputMeta) -> crate::Result<Prism

// DateTime
(TypeIdentifier::DateTime, Bson::DateTime(dt)) => PrismaValue::DateTime(dt.to_chrono().into()),
(TypeIdentifier::DateTime, Bson::Timestamp(ts)) => {
(TypeIdentifier::DateTime, Bson::Timestamp(ts)) =>
{
#[allow(deprecated)]
PrismaValue::DateTime(Utc.timestamp(ts.time as i64, 0).into())
}

Expand Down
3 changes: 3 additions & 0 deletions query-engine/connectors/sql-query-connector/src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ fn row_value_to_prisma_value(p_value: Value, meta: ColumnMetadata<'_>) -> Result
let ts = value.as_integer().unwrap();
let nsecs = ((ts % 1000) * 1_000_000) as u32;
let secs = ts / 1000;
#[allow(deprecated)]
let naive = chrono::NaiveDateTime::from_timestamp(secs, nsecs);
let datetime: DateTime<Utc> = DateTime::from_utc(naive, Utc);

Expand All @@ -188,10 +189,12 @@ fn row_value_to_prisma_value(p_value: Value, meta: ColumnMetadata<'_>) -> Result
PrismaValue::DateTime(dt.with_timezone(&Utc).into())
}
Value::Date(Some(d)) => {
#[allow(deprecated)]
let dt = DateTime::<Utc>::from_utc(d.and_hms(0, 0, 0), Utc);
PrismaValue::DateTime(dt.into())
}
Value::Time(Some(t)) => {
#[allow(deprecated)]
let d = NaiveDate::from_ymd(1970, 1, 1);
let dt = DateTime::<Utc>::from_utc(d.and_time(t), Utc);
PrismaValue::DateTime(dt.into())
Expand Down
2 changes: 2 additions & 0 deletions query-engine/connectors/sql-query-connector/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ pub fn to_prisma_value(quaint_value: Value<'_>) -> crate::Result<PrismaValue> {

Value::Date(d) => d
.map(|d| {
#[allow(deprecated)]
let dt = DateTime::<Utc>::from_utc(d.and_hms(0, 0, 0), Utc);
PrismaValue::DateTime(dt.into())
})
.unwrap_or(PrismaValue::Null),

Value::Time(t) => t
.map(|t| {
#[allow(deprecated)]
let d = NaiveDate::from_ymd(1970, 1, 1);
let dt = DateTime::<Utc>::from_utc(d.and_time(t), Utc);
PrismaValue::DateTime(dt.into())
Expand Down

0 comments on commit a8b91ca

Please sign in to comment.