feat: ability to create a task #14
@ -24,7 +24,22 @@ pub(crate) async fn create_task(new_task: NewTask)
|
||||
|
||||
.values(&new_task)
|
||||
.returning(Task::as_returning())
|
||||
.get_result(&mut connection)
|
||||
.unwrap();
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
.map_err::<ErrorVec<TaskCreateError>, _>(|error| {
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
let error = match error {
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
diesel::result::Error::DatabaseError(
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
diesel::result::DatabaseErrorKind::ForeignKeyViolation, info
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
) => {
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
match info.constraint_name() {
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
Some("tasks_project_id_fkey") => TaskCreateError::ProjectNotFound,
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
_ => TaskCreateError::Error(Error::ServerInternal)
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
},
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
_ => {
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
TaskCreateError::Error(Error::ServerInternal)
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
};
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
vec![error].into()
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
})?;
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
|
||||
Ok(new_task)
|
||||
}
|
||||
|
||||
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() Avoid using Using Replace **Avoid using `unwrap()` for database operations.**
Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message.
Replace `unwrap()` with proper error handling to prevent potential panics.
<!-- This is an auto-generated comment by CodeRabbit -->
|
Avoid using
unwrap()
for database operations.Using
unwrap()
can lead to panics if the database operation fails. Consider handling the error withmap_err
orexpect
with a meaningful message.Replace
unwrap()
with proper error handling to prevent potential panics.Avoid using
unwrap()
for database operations.Using
unwrap()
can lead to panics if the database operation fails. Consider handling the error withmap_err
orexpect
with a meaningful message.Replace
unwrap()
with proper error handling to prevent potential panics.