sort in chronological order
This commit is contained in:
parent
f2eff22ff7
commit
d30c3c059b
@ -148,7 +148,7 @@ class SQLite(Abstract):
|
|||||||
def retrieve(self, path, limit=20, mode=1):
|
def retrieve(self, path, limit=20, mode=1):
|
||||||
with sqlite3.connect(self.dbpath) as con:
|
with sqlite3.connect(self.dbpath) as con:
|
||||||
rv = con.execute("SELECT * FROM comments WHERE path=? AND (? | mode) = ?" \
|
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:
|
for item in rv:
|
||||||
yield self.query2comment(item)
|
yield self.query2comment(item)
|
||||||
|
@ -36,11 +36,11 @@ class TestSQLite(unittest.TestCase):
|
|||||||
self.db.add('/path/', comment(text='Baz'))
|
self.db.add('/path/', comment(text='Baz'))
|
||||||
|
|
||||||
rv = list(self.db.retrieve('/'))
|
rv = list(self.db.retrieve('/'))
|
||||||
assert rv[0].id == 2
|
assert rv[0].id == 1
|
||||||
assert rv[0].text == 'Bar'
|
assert rv[0].text == 'Foo'
|
||||||
|
|
||||||
assert rv[1].id == 1
|
assert rv[1].id == 2
|
||||||
assert rv[1].text == 'Foo'
|
assert rv[1].text == 'Bar'
|
||||||
|
|
||||||
rv = list(self.db.retrieve('/path/'))
|
rv = list(self.db.retrieve('/path/'))
|
||||||
assert rv[0].id == 1
|
assert rv[0].id == 1
|
||||||
|
Loading…
Reference in New Issue
Block a user