From d30c3c059bf34f54b2bcf6c84d9b12ba60a81ded Mon Sep 17 00:00:00 2001 From: posativ Date: Fri, 19 Oct 2012 21:12:56 +0200 Subject: [PATCH] sort in chronological order --- isso/db.py | 2 +- specs/test_db.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/isso/db.py b/isso/db.py index 9e83e87..24dbca7 100644 --- a/isso/db.py +++ b/isso/db.py @@ -148,7 +148,7 @@ class SQLite(Abstract): def retrieve(self, path, limit=20, mode=1): with sqlite3.connect(self.dbpath) as con: rv = con.execute("SELECT * FROM comments WHERE path=? AND (? | mode) = ?" \ - + " ORDER BY id DESC LIMIT ?;", (path, mode, mode, limit)).fetchall() + + " ORDER BY id ASC LIMIT ?;", (path, mode, mode, limit)).fetchall() for item in rv: yield self.query2comment(item) diff --git a/specs/test_db.py b/specs/test_db.py index e5bb52d..602eb86 100644 --- a/specs/test_db.py +++ b/specs/test_db.py @@ -36,11 +36,11 @@ class TestSQLite(unittest.TestCase): self.db.add('/path/', comment(text='Baz')) rv = list(self.db.retrieve('/')) - assert rv[0].id == 2 - assert rv[0].text == 'Bar' + assert rv[0].id == 1 + assert rv[0].text == 'Foo' - assert rv[1].id == 1 - assert rv[1].text == 'Foo' + assert rv[1].id == 2 + assert rv[1].text == 'Bar' rv = list(self.db.retrieve('/path/')) assert rv[0].id == 1