From 0e2897a276166503ba78fe3e1cee501e9a034021 Mon Sep 17 00:00:00 2001 From: Flavian Desverne Date: Fri, 19 Jul 2024 11:32:34 +0200 Subject: [PATCH] fix: improve column type info (#347) --- Cargo.toml | 2 +- src/row.rs | 14 ++++++++++++-- src/tds/codec/token/token_feature_ext_ack.rs | 2 ++ src/tds/codec/token/token_return_value.rs | 1 + src/tds/stream/token.rs | 1 + tests/query.rs | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4f96e962..081e6491 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,7 +172,7 @@ url = "2.2.2" reqwest = "0.11.10" paste = "1.0" indicatif = "0.17" -chrono = "0.4" +chrono = "0.4.38" indoc = "1.0.7" [package.metadata.docs.rs] 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/codec/token/token_feature_ext_ack.rs b/src/tds/codec/token/token_feature_ext_ack.rs index c0686db6..1ba108f9 100644 --- a/src/tds/codec/token/token_feature_ext_ack.rs +++ b/src/tds/codec/token/token_feature_ext_ack.rs @@ -7,11 +7,13 @@ pub struct TokenFeatureExtAck { } #[derive(Debug)] +#[allow(dead_code)] pub enum FedAuthAck { SecurityToken { nonce: Option<[u8; 32]> }, } #[derive(Debug)] +#[allow(dead_code)] pub enum FeatureAck { FedAuth(FedAuthAck), } diff --git a/src/tds/codec/token/token_return_value.rs b/src/tds/codec/token/token_return_value.rs index 70cc220d..183e46be 100644 --- a/src/tds/codec/token/token_return_value.rs +++ b/src/tds/codec/token/token_return_value.rs @@ -2,6 +2,7 @@ use super::BaseMetaDataColumn; use crate::{tds::codec::ColumnData, Error, SqlReadBytes}; #[derive(Debug)] +#[allow(dead_code)] pub struct TokenReturnValue { pub param_ordinal: u16, pub param_name: String, diff --git a/src/tds/stream/token.rs b/src/tds/stream/token.rs index 443d9b0d..35ce0658 100644 --- a/src/tds/stream/token.rs +++ b/src/tds/stream/token.rs @@ -15,6 +15,7 @@ use std::{convert::TryFrom, sync::Arc}; use tracing::{event, Level}; #[derive(Debug)] +#[allow(dead_code)] pub enum ReceivedToken { NewResultset(Arc>), Row(TokenRow<'static>), diff --git a/tests/query.rs b/tests/query.rs index f2177ea2..4cf3c62b 100644 --- a/tests/query.rs +++ b/tests/query.rs @@ -2678,7 +2678,7 @@ where let col = meta.columns().first(); assert_eq!(Some("col"), col.map(|c| c.name())); - assert_eq!(Some(ColumnType::Intn), col.map(|c| c.column_type())); + assert_eq!(Some(ColumnType::Int4), col.map(|c| c.column_type())); } }