]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add failing test for [ticket:2142]
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 23 Apr 2011 19:13:45 +0000 (15:13 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 23 Apr 2011 19:13:45 +0000 (15:13 -0400)
test/dialect/test_postgresql.py

index 647fe8fecf84fa01590c2734aa5e3116ba434af1..118a9eb2718644fac189ba6d276b530bbe716e30 100644 (file)
@@ -1214,6 +1214,33 @@ class MiscTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
             'SELECT DISTINCT ON (mytable.id, mytable.a) mytable.id, '
             'mytable.a \nFROM mytable')
 
+    @testing.fails_if(lambda: True, "[ticket:2142]")
+    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]).alias()
+        q = select([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]).alias('sq')
+        q = select([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"""