From 42c3340f60b21fb138b26b0104307bf9b525077d Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 18 Feb 2021 21:41:34 -0800 Subject: [PATCH] feat(mysql): add TypeInfo to MySqlRawValue --- sqlx-mysql/src/value.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sqlx-mysql/src/value.rs b/sqlx-mysql/src/value.rs index 61f1f0d0..cca97584 100644 --- a/sqlx-mysql/src/value.rs +++ b/sqlx-mysql/src/value.rs @@ -4,7 +4,7 @@ use bytes::Bytes; use sqlx_core::decode::{Error as DecodeError, Result as DecodeResult}; use sqlx_core::{Decode, Runtime}; -use crate::MySql; +use crate::{MySql, MySqlTypeInfo}; /// The format of a raw SQL value for MySQL. /// @@ -22,12 +22,22 @@ pub enum MySqlRawValueFormat { pub struct MySqlRawValue<'r> { value: Option<&'r Bytes>, format: MySqlRawValueFormat, + type_info: &'r MySqlTypeInfo, } // 'r: row impl<'r> MySqlRawValue<'r> { - pub(crate) fn new(value: &'r Option, format: MySqlRawValueFormat) -> Self { - Self { value: value.as_ref(), format } + pub(crate) fn new( + value: &'r Option, + format: MySqlRawValueFormat, + type_info: &'r MySqlTypeInfo, + ) -> Self { + Self { value: value.as_ref(), format, type_info } + } + + /// Returns the type information for this value. + pub fn type_info(&self) -> &'r MySqlTypeInfo { + self.type_info } /// Returns the format of this value.