summaryrefslogtreecommitdiff
path: root/test/dialect/test_postgresql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-04-23 15:05:50 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-04-23 15:05:50 -0400
commit55f87348f38bc05b644905986ee85638281aa3ec (patch)
tree013dadc32136c7810ccaeba4c8dac54b90fb9c90 /test/dialect/test_postgresql.py
parentd216298073ac6657728bdeb56598f3e5124e2d67 (diff)
downloadsqlalchemy-55f87348f38bc05b644905986ee85638281aa3ec.tar.gz
- add test for [ticket:2142]
Diffstat (limited to 'test/dialect/test_postgresql.py')
-rw-r--r--test/dialect/test_postgresql.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py
index de7169579..125b590f1 100644
--- a/test/dialect/test_postgresql.py
+++ b/test/dialect/test_postgresql.py
@@ -1203,6 +1203,33 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL):
"t_1.a AS t_1_a, t_1.b AS t_1_b FROM t AS t_1"
)
+ def test_distinct_on_subquery_anon(self):
+
+ sq = select([self.table]).alias()
+ q = select([self.table.c.id,sq.c.id]).\
+ distinct(sq.c.id).\
+ where(self.table.c.id==sq.c.id)
+
+ self.assert_compile(
+ q,
+ "SELECT DISTINCT ON (anon_1.id) t.id, anon_1.id "
+ "FROM t, (SELECT t.id AS id, t.a AS a, t.b "
+ "AS b FROM t) AS anon_1 WHERE t.id = anon_1.id"
+ )
+
+ def test_distinct_on_subquery_named(self):
+ sq = select([self.table]).alias('sq')
+ q = select([self.table.c.id,sq.c.id]).\
+ distinct(sq.c.id).\
+ where(self.table.c.id==sq.c.id)
+ self.assert_compile(
+ q,
+ "SELECT DISTINCT ON (sq.id) t.id, sq.id "
+ "FROM t, (SELECT t.id AS id, t.a AS a, "
+ "t.b AS b FROM t) AS sq WHERE t.id = sq.id"
+ )
+
+
class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
__only_on__ = 'postgresql'