summaryrefslogtreecommitdiff
path: root/test/sql/test_query.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-01-28 23:43:14 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-01-28 23:43:14 -0500
commitd4c908ded1e9a7923312f3b335835e7e40b6690e (patch)
tree8737395d3494ad31270c1dddb1ade580ceaf8a47 /test/sql/test_query.py
parentd8d03011b8dafe48b71e9eb3bc756d05da54a7bf (diff)
downloadsqlalchemy-d4c908ded1e9a7923312f3b335835e7e40b6690e.tar.gz
- Fixed 0.9 regression where the new sortable support for :class:`.RowProxy`
would lead to ``TypeError`` when compared to non-tuple types as it attempted to apply tuple() to the "other" object unconditionally. The full range of Python comparison operators have now been implemented on :class:`.RowProxy`, using an approach that guarantees a comparison system that is equivalent to that of a tuple, and the "other" object is only coerced if it's an instance of RowProxy. [ticket:2924]
Diffstat (limited to 'test/sql/test_query.py')
-rw-r--r--test/sql/test_query.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index 40c63b179..8cbd01c66 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -304,7 +304,7 @@ class QueryTest(fixtures.TestBase):
def test_row_comparison(self):
- users.insert().execute(user_id = 7, user_name = 'jack')
+ users.insert().execute(user_id = 7, user_name='jack')
rp = users.select().execute().first()
self.assert_(rp == rp)
@@ -317,6 +317,30 @@ class QueryTest(fixtures.TestBase):
self.assert_(not (rp != equal))
self.assert_(not (equal != equal))
+ def endless():
+ while True:
+ yield 1
+ self.assert_(rp != endless())
+ self.assert_(endless() != rp)
+
+ # test that everything compares the same
+ # as it would against a tuple
+ import operator
+ for compare in [False, 8, endless(), 'xyz', (7, 'jack')]:
+ for op in [
+ operator.eq, operator.ne, operator.gt,
+ operator.lt, operator.ge, operator.le
+ ]:
+ eq_(
+ op(equal, compare),
+ op(rp, compare)
+ )
+ eq_(
+ op(compare, equal),
+ op(compare, rp)
+ )
+
+
@testing.provide_metadata
def test_column_label_overlap_fallback(self):
content = Table('content', self.metadata,