set parent to null if parent is not top-level comment

This commit is contained in:
Martin Zimmermann 2014-04-20 18:00:28 +02:00
parent 24adafa25b
commit ce14726f2f

View File

@ -37,6 +37,12 @@ class Comments:
Add new comment to DB and return a mapping of :attribute:`fields` and Add new comment to DB and return a mapping of :attribute:`fields` and
database values. 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([ self.db.execute([
'INSERT INTO comments (', 'INSERT INTO comments (',
' tid, parent,' ' tid, parent,'