From f36d9bb9ba56ede845bea0543fffee6dcc75753f Mon Sep 17 00:00:00 2001 From: Daniel Akhterov Date: Tue, 10 Sep 2019 23:29:11 -0700 Subject: [PATCH] Update ToSql and FromSql to be Db dependent --- src/mariadb/types/character.rs | 2 +- src/mariadb/types/numeric.rs | 8 ++++---- src/postgres/types/character.rs | 2 +- src/postgres/types/numeric.rs | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mariadb/types/character.rs b/src/mariadb/types/character.rs index bdc55f6b..5c862506 100644 --- a/src/mariadb/types/character.rs +++ b/src/mariadb/types/character.rs @@ -37,7 +37,7 @@ impl ToSql for &'_ str { impl ToSql for String { #[inline] fn to_sql(self, buf: &mut Vec) -> IsNull { - self.as_str().to_sql(buf) + <&str as ToSql>::to_sql(self.as_str(), buf) } } diff --git a/src/mariadb/types/numeric.rs b/src/mariadb/types/numeric.rs index bc0e2f4d..006359c8 100644 --- a/src/mariadb/types/numeric.rs +++ b/src/mariadb/types/numeric.rs @@ -102,14 +102,14 @@ impl HasSqlType for MariaDb { impl ToSql for f32 { #[inline] fn to_sql(self, buf: &mut Vec) -> IsNull { - (self.to_bits() as i32).to_sql(buf) + >::to_sql((self.to_bits() as i32), buf) } } impl FromSql for f32 { #[inline] fn from_sql(buf: Option<&[u8]>) -> Self { - f32::from_bits(i32::from_sql(buf) as u32) + f32::from_bits(>::from_sql(buf) as u32) } } @@ -127,13 +127,13 @@ impl HasSqlType for MariaDb { impl ToSql for f64 { #[inline] fn to_sql(self, buf: &mut Vec) -> IsNull { - (self.to_bits() as i64).to_sql(buf) + >::to_sql((self.to_bits() as i64), buf) } } impl FromSql for f64 { #[inline] fn from_sql(buf: Option<&[u8]>) -> Self { - f64::from_bits(i64::from_sql(buf) as u64) + f64::from_bits(>::from_sql(buf) as u64) } } diff --git a/src/postgres/types/character.rs b/src/postgres/types/character.rs index 135d8e0a..2287b244 100644 --- a/src/postgres/types/character.rs +++ b/src/postgres/types/character.rs @@ -36,7 +36,7 @@ impl ToSql for &'_ str { impl ToSql for String { #[inline] fn to_sql(self, buf: &mut Vec) -> IsNull { - self.as_str().to_sql(buf) + <&str as ToSql>::to_sql(self.as_str(), buf) } } diff --git a/src/postgres/types/numeric.rs b/src/postgres/types/numeric.rs index b106649a..4fab71b5 100644 --- a/src/postgres/types/numeric.rs +++ b/src/postgres/types/numeric.rs @@ -101,14 +101,14 @@ impl HasSqlType for Postgres { impl ToSql for f32 { #[inline] fn to_sql(self, buf: &mut Vec) -> IsNull { - (self.to_bits() as i32).to_sql(buf) + >::to_sql(self.to_bits() as i32, buf) } } impl FromSql for f32 { #[inline] fn from_sql(buf: Option<&[u8]>) -> Self { - f32::from_bits(i32::from_sql(buf) as u32) + f32::from_bits(>::from_sql(buf) as u32) } } @@ -126,13 +126,13 @@ impl HasSqlType for Postgres { impl ToSql for f64 { #[inline] fn to_sql(self, buf: &mut Vec) -> IsNull { - (self.to_bits() as i64).to_sql(buf) + >::to_sql(self.to_bits() as i64, buf) } } impl FromSql for f64 { #[inline] fn from_sql(buf: Option<&[u8]>) -> Self { - f64::from_bits(i64::from_sql(buf) as u64) + f64::from_bits(>::from_sql(buf) as u64) } }