From ce14726f2fceb86b65f064c59ff5110407b66924 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Sun, 20 Apr 2014 18:00:28 +0200 Subject: [PATCH] set parent to null if parent is not top-level comment --- isso/db/comments.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/isso/db/comments.py b/isso/db/comments.py index 063eb0c..ef97eeb 100644 --- a/isso/db/comments.py +++ b/isso/db/comments.py @@ -37,6 +37,12 @@ class Comments: Add new comment to DB and return a mapping of :attribute:`fields` and database values. """ + + if "parent" in c: + rv = self.db.execute("SELECT parent FROM comments WHERE id=?", (c.get('parent'), )).fetchone() + if rv and rv[0] is not None: + c["parent"] = None + self.db.execute([ 'INSERT INTO comments (', ' tid, parent,'