diff --git a/src/row.rs b/src/row.rs index 59edfd8d..5441be70 100644 --- a/src/row.rs +++ b/src/row.rs @@ -123,11 +123,21 @@ impl From<&TypeInfo> for ColumnType { }, TypeInfo::VarLenSized(cx) => match cx.r#type() { VarLenType::Guid => Self::Guid, - VarLenType::Intn => Self::Intn, + VarLenType::Intn => match cx.len() { + 1 => Self::Int1, + 2 => Self::Int2, + 4 => Self::Int4, + 8 => Self::Int8, + _ => Self::Intn, + }, VarLenType::Bitn => Self::Bitn, VarLenType::Decimaln => Self::Decimaln, VarLenType::Numericn => Self::Numericn, - VarLenType::Floatn => Self::Floatn, + VarLenType::Floatn => match cx.len() { + 4 => Self::Float4, + 8 => Self::Float8, + _ => Self::Floatn, + }, VarLenType::Money => Self::Money, VarLenType::Datetimen => Self::Datetimen, #[cfg(feature = "tds73")] diff --git a/src/tds/time/chrono.rs b/src/tds/time/chrono.rs index f6de5001..0f58ddd0 100644 --- a/src/tds/time/chrono.rs +++ b/src/tds/time/chrono.rs @@ -81,7 +81,7 @@ from_sql!( let offset = chrono::Duration::minutes(dto.offset as i64); let naive = NaiveDateTime::new(date, time).sub(offset); - chrono::DateTime::from_naive_utc_and_offset(naive, Utc) + chrono::DateTime::from_utc(naive, Utc) }), ColumnData::DateTime2(ref dt2) => dt2.map(|dt2| { let date = from_days(dt2.date.days() as i64, 1); @@ -89,7 +89,7 @@ from_sql!( let time = NaiveTime::from_hms_opt(0,0,0).unwrap() + chrono::Duration::nanoseconds(ns); let naive = NaiveDateTime::new(date, time); - chrono::DateTime::from_naive_utc_and_offset(naive, Utc) + chrono::DateTime::from_utc(naive, Utc) }); chrono::DateTime: ColumnData::DateTimeOffset(ref dto) => dto.map(|dto| { let date = from_days(dto.datetime2.date.days() as i64, 1); @@ -99,7 +99,7 @@ from_sql!( let offset = FixedOffset::east_opt((dto.offset as i32) * 60).unwrap(); let naive = NaiveDateTime::new(date, time); - chrono::DateTime::from_naive_utc_and_offset(naive, offset) + chrono::DateTime::from_utc(naive, offset) }) ); diff --git a/tests/query.rs b/tests/query.rs index f2177ea2..527ab025 100644 --- a/tests/query.rs +++ b/tests/query.rs @@ -2237,7 +2237,7 @@ where .unwrap() .and_hms_opt(16, 20, 0) .unwrap(); - let dt: DateTime = DateTime::from_naive_utc_and_offset(naive, Utc); + let dt: DateTime = DateTime::from_utc(naive, Utc); let row = conn .query("SELECT @P1", &[&dt]) @@ -2276,7 +2276,7 @@ where .unwrap(); let fixed = FixedOffset::east_opt(3600 * 3).unwrap(); - let dt: DateTime = DateTime::from_naive_utc_and_offset(naive, fixed); + let dt: DateTime = DateTime::from_utc(naive, fixed); let row = conn .query("SELECT @P1", &[&dt]) @@ -2314,7 +2314,7 @@ where .and_hms_opt(16, 20, 0) .unwrap(); let fixed = FixedOffset::east_opt(3600 * 3).unwrap(); - let dt: DateTime = DateTime::from_naive_utc_and_offset(naive, fixed); + let dt: DateTime = DateTime::from_utc(naive, fixed); let row = conn .query(format!("SELECT CAST('{}' AS datetimeoffset(7))", dt), &[])