From f9861c881ea92e385f05271d76f832347d002e24 Mon Sep 17 00:00:00 2001 From: retorted <201078195+retorted@users.noreply.github.com> Date: Mon, 7 Apr 2025 15:39:19 +0100 Subject: [PATCH 1/2] Re-export sqlx::Type as welds::WeldsType --- welds-connections/src/lib.rs | 2 ++ welds/src/lib.rs | 4 ++++ welds/src/prelude.rs | 2 ++ 3 files changed, 8 insertions(+) diff --git a/welds-connections/src/lib.rs b/welds-connections/src/lib.rs index b0cf094..0e9d14d 100644 --- a/welds-connections/src/lib.rs +++ b/welds-connections/src/lib.rs @@ -18,6 +18,8 @@ pub mod row; pub mod sqlite; pub mod trace; pub mod transaction; +#[cfg(any(feature = "mysql", feature = "sqlite", feature = "postgres"))] +pub use sqlx::Type as WeldsType; pub struct Fetch<'s, 'args, 't> { pub sql: &'s str, diff --git a/welds/src/lib.rs b/welds/src/lib.rs index 7f2a9f2..622b096 100644 --- a/welds/src/lib.rs +++ b/welds/src/lib.rs @@ -180,3 +180,7 @@ pub use welds_connections::{Client, Row, Syntax, TransactStart}; /// Re-export the Macro used to make models pub use welds_macros::WeldsModel; + +/// Re-export sqlx::Type as WeldsType for using custom types in models +#[cfg(any(feature = "mysql", feature = "sqlite", feature = "postgres"))] +pub use welds_connections::WeldsType; diff --git a/welds/src/prelude.rs b/welds/src/prelude.rs index 6d4bcc8..7d20a67 100644 --- a/welds/src/prelude.rs +++ b/welds/src/prelude.rs @@ -3,3 +3,5 @@ pub use crate::TransactStart; pub use crate::WeldsModel; pub use crate::exts::{VecRowExt, VecStateExt}; pub use crate::state::DbState; +#[cfg(any(feature = "mysql", feature = "sqlite", feature = "postgres"))] +pub use crate::WeldsType; From 57133337b5bf7573e17095f153863685f973c224 Mon Sep 17 00:00:00 2001 From: retorted <201078195+retorted@users.noreply.github.com> Date: Mon, 7 Apr 2025 15:39:38 +0100 Subject: [PATCH 2/2] Use welds::WeldsType in a test --- tests/postgres/src/models/enums/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/postgres/src/models/enums/mod.rs b/tests/postgres/src/models/enums/mod.rs index 41bcc97..b3eb300 100644 --- a/tests/postgres/src/models/enums/mod.rs +++ b/tests/postgres/src/models/enums/mod.rs @@ -1,6 +1,6 @@ // only for PostgreSQL to match a type definition -#[derive(sqlx::Type, Debug, Clone, PartialEq)] +#[derive(welds::WeldsType, Debug, Clone, PartialEq)] #[sqlx(type_name = "Color")] pub enum Color { Red,