Commit 3f115201 authored by Kipp Cannon's avatar Kipp Cannon

dbtables: add .__reversed__() support

- also, set ordering in iter() to ensure reversed() and iter() yield rows in opposite order
parent ed01d8cb
......@@ -760,7 +760,13 @@ class DBTable(table.Table):
def __iter__(self):
cursor = self.connection.cursor()
cursor.execute("SELECT * FROM %s" % self.Name)
cursor.execute("SELECT * FROM %s ORDER BY rowid ASC" % self.Name)
for values in cursor:
yield self.row_from_cols(values)
def __reversed__(self):
cursor = self.connection.cursor()
cursor.execute("SELECT * FROM %s ORDER BY rowid DESC" % self.Name)
for values in cursor:
yield self.row_from_cols(values)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment