Cleaned up constraints a little.
This commit is contained in:
@@ -23,7 +23,7 @@ impl From<sqlx::Error> for DatabaseError {
|
||||
let constraint = db_err
|
||||
.constraint()
|
||||
.map(Constraint::from)
|
||||
.unwrap_or(Constraint::Unknown(None));
|
||||
.unwrap_or(Constraint::Unnamed);
|
||||
|
||||
DatabaseError::ForeignKeyViolation {
|
||||
constraint,
|
||||
@@ -37,14 +37,17 @@ impl From<sqlx::Error> for DatabaseError {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
|
||||
pub enum Constraint {
|
||||
#[error("recurring transaction source account constraint violation")]
|
||||
#[error("recurring transaction source account constraint")]
|
||||
RecurringTransactionSourceAccount,
|
||||
|
||||
#[error("recurring transaction destination account constraint violation")]
|
||||
#[error("recurring transaction destination account constraint")]
|
||||
RecurringTransactionDestinationAccount,
|
||||
|
||||
#[error("unknown constraint violation: {0:?}")]
|
||||
Unknown(Option<String>),
|
||||
#[error("unknown constraint ({0:?})")]
|
||||
Unknown(String),
|
||||
|
||||
#[error("unnamed constraint")]
|
||||
Unnamed,
|
||||
}
|
||||
|
||||
impl From<&str> for Constraint {
|
||||
@@ -56,7 +59,7 @@ impl From<&str> for Constraint {
|
||||
"fk_recurring_transactions_destination_account" => {
|
||||
Constraint::RecurringTransactionDestinationAccount
|
||||
}
|
||||
_ => Constraint::Unknown(Some(constraint.to_string())),
|
||||
_ => Constraint::Unknown(constraint.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user