You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
currently sqlx only support enum defined in postgres, but it's not convenient for those "enum" in rust but stored as text/varchar in postgres, what I call as TextEnum, this trait should be derived via proc macro.
we do have a version of declare macro
macro_rules! as_sql_text {($ident:ident) => {impl::sqlx::Type<::sqlx::Postgres> for $ident {fn type_info() -> ::sqlx::postgres::PgTypeInfo{::sqlx::postgres::PgTypeInfo::with_oid(1043)}}impl sqlx::Decode<'_,::sqlx::Postgres> for $ident {fn decode(
value: <::sqlx::Postgresas::sqlx::database::HasValueRef<'_>>::ValueRef,) -> Result<Self,::sqlx::error::BoxDynError> {use std::str::FromStr;let value = <&stras::sqlx::Decode<::sqlx::Postgres>>::decode(value)?;Ok(Self::from_str(value)?)}}impl sqlx::Encode<'_,::sqlx::Postgres> for $ident {fn encode_by_ref(&self, buf:&mut <::sqlx::Postgresas::sqlx::database::HasArguments<'_>>::ArgumentBuffer,) -> ::sqlx::encode::IsNull{let x:&str = self.as_ref();
<&stras::sqlx::Encode<::sqlx::Postgres>>::encode_by_ref(&x, buf)}}};}
The text was updated successfully, but these errors were encountered:
currently sqlx only support enum defined in postgres, but it's not convenient for those "enum" in rust but stored as text/varchar in postgres, what I call as
TextEnum
, this trait should be derived via proc macro.we do have a version of declare macro
The text was updated successfully, but these errors were encountered: