From 02f21ffcf366da406795334d2fc6908a2f3c9b2f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 19 Nov 2013 19:29:18 -0500 Subject: - The :class:`.RowProxy` object is now sortable in Python as a regular tuple is; this is accomplished via ensuring tuple() conversion on both sides within the ``__eq__()`` method as well as the addition of a ``__lt__()`` method. [ticket:2848] --- test/sql/test_query.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/sql/test_query.py') diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 8e619fe74..8c5e1db4d 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -1090,6 +1090,19 @@ class QueryTest(fixtures.TestBase): eq_(len(r), 1) + def test_sorting_in_python(self): + users.insert().execute( + dict(user_id=1, user_name='foo'), + dict(user_id=2, user_name='bar'), + dict(user_id=3, user_name='def'), + ) + + rows = users.select().order_by(users.c.user_name).execute().fetchall() + + eq_(rows, [(2, 'bar'), (3, 'def'), (1, 'foo')]) + + eq_(sorted(rows), [(1, 'foo'), (2, 'bar'), (3, 'def')]) + def test_column_order_with_simple_query(self): # should return values in column definition order users.insert().execute(user_id=1, user_name='foo') -- cgit v1.2.1