This commit is contained in:
Lunny Xiao 2025-07-15 22:36:42 -07:00
parent c4f7e319d0
commit 64dec560dc

View File

@ -1158,7 +1158,7 @@ func DeleteComment(ctx context.Context, comment *Comment) error {
// delete review if the comment is the last comment of the review
if comment.ReviewID > 0 {
if _, err := db.GetEngine(ctx).ID(comment.ReviewID).
Where("(SELECT count(id) FROM comment WHERE review_id = ?) == 0", comment.ReviewID).
Where("NOT EXISTS (SELECT 1 FROM comment WHERE review_id = ?)", comment.ReviewID).
Delete(new(Review)); err != nil {
return err
}