store_sqlite: Implement put_object overwrite parameter

This commit is contained in:
Lennart
2024-10-28 17:20:53 +01:00
parent cce3e260af
commit f3672ff986
3 changed files with 36 additions and 10 deletions

View File

@@ -11,6 +11,13 @@ impl From<sqlx::Error> for Error {
fn from(value: sqlx::Error) -> Self {
match value {
sqlx::Error::RowNotFound => Error::StoreError(rustical_store::Error::NotFound),
sqlx::Error::Database(err) => {
if err.is_unique_violation() {
Error::StoreError(rustical_store::Error::AlreadyExists)
} else {
Error::SqlxError(sqlx::Error::Database(err))
}
}
err => Error::SqlxError(err),
}
}