- changed milestone to 0.6.8
"distinct on" + subquery
Issue #2142
resolved
diff -r dac31fa95b4416316e8b7c419b08410c42c0b287 test/dialect/test_postgresql.py
--- a/test/dialect/test_postgresql.py Fri Apr 15 00:43:01 2011 -0400
+++ b/test/dialect/test_postgresql.py Thu Apr 21 12:27:42 2011 -0500
@@ -1214,6 +1214,32 @@
'SELECT DISTINCT ON (mytable.id, mytable.a) mytable.id, '
'mytable.a \nFROM mytable')
+ def test_distinct_on_subquery(self):
+ t1 = Table('mytable1', MetaData(testing.db), Column('id',
+ Integer, primary_key=True), Column('a', String(8)))
+ t2 = Table('mytable2', MetaData(testing.db), Column('id',
+ Integer, primary_key=True), Column('a', String(8)))
+
+ sq = select([t1](t1)).alias()
+ q = select([t2.c.id,sq.c.id](t2.c.id,sq.c.id), distinct=sq.c.id).where(t2.c.id==sq.c.id)
+ self.assert_compile(
+ q,
+ "SELECT DISTINCT ON (anon_1.id) mytable2.id, anon_1.id "
+ "FROM mytable2, (SELECT mytable1.id AS id, mytable1.a AS a "
+ "FROM mytable1) AS anon_1 "
+ "WHERE mytable2.id = anon_1.id"
+ )
+
+ sq = select([t1](t1)).alias('sq')
+ q = select([t2.c.id,sq.c.id](t2.c.id,sq.c.id), distinct=sq.c.id).where(t2.c.id==sq.c.id)
+ self.assert_compile(
+ q,
+ "SELECT DISTINCT ON (sq.id) mytable2.id, sq.id "
+ "FROM mytable2, (SELECT mytable1.id AS id, mytable1.a AS a "
+ "FROM mytable1) AS sq "
+ "WHERE mytable2.id = sq.id"
+ )
+
def test_schema_reflection(self):
"""note: this test requires that the 'test_schema' schema be
separate and accessible by the test user"""
Comments (5)
-
reporter -
reporter yeah this is some mechanism that was updated so I'd recommend upgrading to 0.7. the failing test with a decorator is added in fb9aba2155be4da60a54b707f3b40dc2853a1e6d.
-
reporter - changed milestone to 0.6.xx
-
reporter - changed status to wontfix
not worth a backport
-
reporter - removed milestone
Removing milestone: 0.6.xx (automated comment)
- Log in to comment
this is an 0.6 only bug. the system was rewritten in 0.7 and the above works fine and the test adapted will be coming up in 55f87348f38bc05b644905986ee85638281aa3ec.