From f0dbd3410f9c55fcf7470ee158d423d1bcd12353 Mon Sep 17 00:00:00 2001 From: Flori <39242991+bitfl0wer@users.noreply.github.com> Date: Sun, 25 Aug 2024 21:51:12 +0200 Subject: [PATCH] sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros --- Cargo.lock | 2 +- chorus-macros/Cargo.toml | 2 +- chorus-macros/src/lib.rs | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 244e0e68..2ad41745 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -282,7 +282,7 @@ dependencies = [ [[package]] name = "chorus-macros" -version = "0.4.1" +version = "0.5.0" dependencies = [ "async-trait", "quote", diff --git a/chorus-macros/Cargo.toml b/chorus-macros/Cargo.toml index 6aa416a1..4efc3720 100644 --- a/chorus-macros/Cargo.toml +++ b/chorus-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chorus-macros" -version = "0.4.1" +version = "0.5.0" edition = "2021" license = "MPL-2.0" description = "Macros for the chorus crate." diff --git a/chorus-macros/src/lib.rs b/chorus-macros/src/lib.rs index c2a23c5a..d2797e75 100644 --- a/chorus-macros/src/lib.rs +++ b/chorus-macros/src/lib.rs @@ -166,22 +166,21 @@ pub fn sqlx_bitflag_derive(input: TokenStream) -> TokenStream { #[cfg(feature = "sqlx")] impl sqlx::Type for #name { fn type_info() -> sqlx::postgres::PgTypeInfo { - as sqlx::Type>::type_info() + >::type_info() } } #[cfg(feature = "sqlx")] impl<'q> sqlx::Encode<'q, sqlx::Postgres> for #name { fn encode_by_ref(&self, buf: &mut ::ArgumentBuffer<'q>) -> Result { - as sqlx::Encode>::encode_by_ref(&self.bits().to_be_bytes().into(), buf) + >::encode_by_ref(&self.bits().into(), buf) } } #[cfg(feature = "sqlx")] impl<'q> sqlx::Decode<'q, sqlx::Postgres> for #name { fn decode(value: ::ValueRef<'q>) -> Result { - let vec = as sqlx::Decode>::decode(value)?; - Ok(Self::from_bits(vec_u8_to_u64(vec)).unwrap()) + >::decode(value).map(|v| Self::from_bits_truncate(v.to_uint())) } }