From a472be41d8d710b66e09b024ecaaaf0c89006963 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Wed, 21 Jan 2015 00:12:24 +0000 Subject: [PATCH] Fix thread location not being updated when post is deleted. A thread table has its own modified attribute which needed to be reset. --- forum.nim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/forum.nim b/forum.nim index fb28493..7f1bc69 100644 --- a/forum.nim +++ b/forum.nim @@ -425,6 +425,14 @@ proc edit(c: var TForumData, postId: int): bool = # whole thread has been deleted, so: c.threadId = unselectedThread discard tryExec(db, sql"delete from thread_fts where id not in (select thread from post)") + else: + # Update corresponding threads modified field. + let getModifiedSql = "(select creation from post where post.thread = ?" & + " order by creation desc limit 1)" + let updateSql = sql("update thread set modified=" & getModifiedSql & + " where id = ?") + if not tryExec(db, updateSql, $c.threadId, $c.threadId): + return setError(c, "", "database error") result = true else: checkOwnership(c, $postId)