Replies: 2 comments
-
|
I managed to make it work by replacing .exprs_panic(vec![
...
Expr::val(appointment.status).as_enum(Alias::new("appointment_status"))
])It forced me to move all items from .exprs_panic(vec![
Expr::val(appointment.id).into(),
Expr::val(appointment.working_day_id).into(),
Expr::val(appointment.client_id).into(),
Expr::val(appointment.specialist_id).into(),
Expr::val(appointment.time_slot.start_time).into(),
Expr::val(appointment.time_slot.end_time).into(),
Expr::val(appointment.status).as_enum(Alias::new("appointment_status"))
])Could someone explain what is the difference between the two of these approaches? And why second approach make it work? P.S. I tried to read the documentation as carefully as possible This is my enum implementation to make it work. #[derive(sqlx::Type, Debug, Copy, Clone)]
#[sqlx(type_name = "appointment_status", rename_all = "SCREAMING_SNAKE_CASE")]
pub enum AppointmentStatus {
Pending,
Done,
Declined,
}
impl From<AppointmentStatus> for sea_query::Value {
fn from(appointment_status: AppointmentStatus) -> Self {
sea_query::Value::String(Some(Box::new(appointment_status.as_str().to_owned())))
}
}
impl AppointmentStatus {
pub fn from_str(s: &str) -> Option<Self> {
match s {
"PENDING" => Some(AppointmentStatus::Pending),
"DECLINED" => Some(AppointmentStatus::Declined),
"DONE" => Some(AppointmentStatus::Done),
_ => None,
}
}
pub fn as_str(&self) -> &'static str {
match self {
AppointmentStatus::Pending => "PENDING",
AppointmentStatus::Declined => "DECLINED",
AppointmentStatus::Done => "DONE",
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Can you try |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have rust enum
I have a builder
Whenever I try to run a function it shows an error
Could you help me to understand how to work with
rust enums+sea_query+postgres enum?Beta Was this translation helpful? Give feedback.
All reactions