X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_schema%2Fsrc%2Fimpls%2Fcomment.rs;h=5346343264036523d86359132183463de95a0b01;hb=92568956353f21649ed9aff68b42699c9d036f30;hp=ea66347dba69fb85a7a4e9a55f9b3e3b82788d87;hpb=bef76630c5d74805ff367bfab787d72498b6927d;p=lemmy.git diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index ea66347d..53463432 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -25,7 +25,7 @@ use url::Url; impl Comment { pub async fn permadelete_for_creator( - pool: &DbPool, + pool: &mut DbPool<'_>, for_creator_id: PersonId, ) -> Result, Error> { let conn = &mut get_conn(pool).await?; @@ -41,7 +41,7 @@ impl Comment { } pub async fn update_removed_for_creator( - pool: &DbPool, + pool: &mut DbPool<'_>, for_creator_id: PersonId, new_removed: bool, ) -> Result, Error> { @@ -53,7 +53,7 @@ impl Comment { } pub async fn create( - pool: &DbPool, + pool: &mut DbPool<'_>, comment_form: &CommentInsertForm, parent_path: Option<&Ltree>, ) -> Result { @@ -123,7 +123,10 @@ where ca.comment_id = c.id" inserted_comment } } - pub async fn read_from_apub_id(pool: &DbPool, object_id: Url) -> Result, Error> { + pub async fn read_from_apub_id( + pool: &mut DbPool<'_>, + object_id: Url, + ) -> Result, Error> { let conn = &mut get_conn(pool).await?; let object_id: DbUrl = object_id.into(); Ok( @@ -153,23 +156,23 @@ impl Crud for Comment { type InsertForm = CommentInsertForm; type UpdateForm = CommentUpdateForm; type IdType = CommentId; - async fn read(pool: &DbPool, comment_id: CommentId) -> Result { + async fn read(pool: &mut DbPool<'_>, comment_id: CommentId) -> Result { let conn = &mut get_conn(pool).await?; comment.find(comment_id).first::(conn).await } - async fn delete(pool: &DbPool, comment_id: CommentId) -> Result { + async fn delete(pool: &mut DbPool<'_>, comment_id: CommentId) -> Result { let conn = &mut get_conn(pool).await?; diesel::delete(comment.find(comment_id)).execute(conn).await } /// This is unimplemented, use [[Comment::create]] - async fn create(_pool: &DbPool, _comment_form: &Self::InsertForm) -> Result { + async fn create(_pool: &mut DbPool<'_>, _comment_form: &Self::InsertForm) -> Result { unimplemented!(); } async fn update( - pool: &DbPool, + pool: &mut DbPool<'_>, comment_id: CommentId, comment_form: &Self::UpdateForm, ) -> Result { @@ -185,7 +188,7 @@ impl Crud for Comment { impl Likeable for CommentLike { type Form = CommentLikeForm; type IdType = CommentId; - async fn like(pool: &DbPool, comment_like_form: &CommentLikeForm) -> Result { + async fn like(pool: &mut DbPool<'_>, comment_like_form: &CommentLikeForm) -> Result { use crate::schema::comment_like::dsl::{comment_id, comment_like, person_id}; let conn = &mut get_conn(pool).await?; insert_into(comment_like) @@ -197,7 +200,7 @@ impl Likeable for CommentLike { .await } async fn remove( - pool: &DbPool, + pool: &mut DbPool<'_>, person_id_: PersonId, comment_id_: CommentId, ) -> Result { @@ -216,7 +219,10 @@ impl Likeable for CommentLike { #[async_trait] impl Saveable for CommentSaved { type Form = CommentSavedForm; - async fn save(pool: &DbPool, comment_saved_form: &CommentSavedForm) -> Result { + async fn save( + pool: &mut DbPool<'_>, + comment_saved_form: &CommentSavedForm, + ) -> Result { use crate::schema::comment_saved::dsl::{comment_id, comment_saved, person_id}; let conn = &mut get_conn(pool).await?; insert_into(comment_saved) @@ -227,7 +233,10 @@ impl Saveable for CommentSaved { .get_result::(conn) .await } - async fn unsave(pool: &DbPool, comment_saved_form: &CommentSavedForm) -> Result { + async fn unsave( + pool: &mut DbPool<'_>, + comment_saved_form: &CommentSavedForm, + ) -> Result { use crate::schema::comment_saved::dsl::{comment_id, comment_saved, person_id}; let conn = &mut get_conn(pool).await?; diesel::delete( @@ -242,6 +251,9 @@ impl Saveable for CommentSaved { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ newtypes::LanguageId, source::{ @@ -269,6 +281,7 @@ mod tests { #[serial] async fn test_crud() { let pool = &build_db_pool_for_tests().await; + let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()) .await