summaryrefslogtreecommitdiff
path: root/test/dialect/test_postgresql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-11-25 12:20:13 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-11-25 12:20:13 -0500
commit77f641429f019d06cc467ec4e57ae94f808d70bd (patch)
tree94ddacadb8915d19d3ee3cdf7a3771fa63ba0184 /test/dialect/test_postgresql.py
parent5247c244ca6595f2685f1c0c271618eda7cb5e62 (diff)
downloadsqlalchemy-77f641429f019d06cc467ec4e57ae94f808d70bd.tar.gz
- Fixed operator precedence rules for multiple
chains of a single non-associative operator. I.e. "x - (y - z)" will compile as "x - (y - z)" and not "x - y - z". Also works with labels, i.e. "x - (y - z).label('foo')" [ticket:1984] - Single element tuple expressions inside an IN clause parenthesize correctly, also from [ticket:1984], added tests for PG - re-fix again importlater, [ticket:1983]
Diffstat (limited to 'test/dialect/test_postgresql.py')
-rw-r--r--test/dialect/test_postgresql.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py
index 150dacf18..92c089480 100644
--- a/test/dialect/test_postgresql.py
+++ b/test/dialect/test_postgresql.py
@@ -2046,3 +2046,34 @@ class MatchTest(TestBase, AssertsCompiledSQL):
matchtable.c.title.match('nutshells'
)))).order_by(matchtable.c.id).execute().fetchall()
eq_([1, 3, 5], [r.id for r in results])
+
+
+class TupleTest(TestBase):
+ __only_on__ = 'postgresql'
+
+ def test_tuple_containment(self):
+
+ for test, exp in [
+ ([('a', 'b')], True),
+ ([('a', 'c')], False),
+ ([('f', 'q'), ('a', 'b')], True),
+ ([('f', 'q'), ('a', 'c')], False)
+ ]:
+ eq_(
+ testing.db.execute(
+ select([
+ tuple_(
+ literal_column("'a'"),
+ literal_column("'b'")
+ ).\
+ in_([
+ tuple_(*[
+ literal_column("'%s'" % letter)
+ for letter in elem
+ ]) for elem in test
+ ])
+ ])
+ ).scalar(),
+ exp
+ )
+