Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(common_utils): manually implement diesel queryable for email newtype (#1072)

ItsMeShashank35196493c450
diff --git a/crates/common_utils/src/pii.rs b/crates/common_utils/src/pii.rs
index f56df89b25..d4b94c1a19 100644
--- a/crates/common_utils/src/pii.rs
+++ b/crates/common_utils/src/pii.rs
@@ -117,19 +117,23 @@ where
}
/// Email address
#[derive(
- serde::Serialize,
- serde::Deserialize,
- Debug,
- Clone,
- PartialEq,
- Eq,
- Default,
- Queryable,
- AsExpression,
+ serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, Default, AsExpression,
)]
#[diesel(sql_type = diesel::sql_types::Text)]
pub struct Email(Secret<String, EmailStrategy>);
+impl<DB> Queryable<diesel::sql_types::Text, DB> for Email
+where
+ DB: Backend,
+ Self: FromSql<sql_types::Text, DB>,
+{
+ type Row = Self;
+
+ fn build(row: Self::Row) -> deserialize::Result<Self> {
+ Ok(row)
+ }
+}
+
impl<DB> FromSql<sql_types::Text, DB> for Email
where
DB: Backend,