From dcb89f52d6c7a0dac6d0cd769ea00c31da7d8dcd Mon Sep 17 00:00:00 2001 From: dullbananas Date: Mon, 18 Dec 2023 02:31:39 -0700 Subject: [PATCH] Don't update comment_aggregates if updating path fails (#4281) --- crates/db_schema/src/impls/comment.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index aef399c59..7173b79d2 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -87,7 +87,7 @@ impl Comment { let updated_comment = diesel::update(comment.find(comment_id)) .set(path.eq(ltree)) .get_result::(conn) - .await; + .await?; // Update the child count for the parent comment_aggregates // You could do this with a trigger, but since you have to do this manually anyway, @@ -121,7 +121,7 @@ where ca.comment_id = c.id" sql_query(update_child_count_stmt).execute(conn).await?; } } - updated_comment + Ok(updated_comment) }) as _ }) .await