use thiserror::Error;

#[derive(Debug, Error)]
pub enum UpsertError {
    #[error("no values provided for upsert")]
    EmptyValues,

    #[error("no fields provided for upsert")]
    EmptyFields,

    #[error("no conflict fields provided for upsert")]
    EmptyConflictFields,

    #[error("version field '{0}' not found in fields list")]
    VersionFieldNotFound(String),

    #[error("field count mismatch: expected {expected}, got {actual}")]
    FieldCountMismatch { expected: usize, actual: usize },

    #[error("database error: {0}")]
    Database(#[from] sqlx::Error),
}

pub type Result<T> = std::result::Result<T, UpsertError>;
