]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Added a test for the SELECT DISTINCT ON postgresqlism.
authorJason Kirtland <jek@discorporate.us>
Wed, 22 Aug 2007 07:33:03 +0000 (07:33 +0000)
committerJason Kirtland <jek@discorporate.us>
Wed, 22 Aug 2007 07:33:03 +0000 (07:33 +0000)
Test currently fails due to two problems in postgres.py, but I'm leaving
it uncorrected for now as its not clear what the original intent was
for lists.

test/dialect/postgres.py

index 221f7660a9f990861f8bccbbea3513c2fb25f9ad..c12115c9aea7b612b3d24dfad41be497b7c075ea 100644 (file)
@@ -114,6 +114,24 @@ class MiscTest(AssertMixin):
         finally:
             t.drop(checkfirst=True)
 
+    @testing.supported('postgres')
+    def test_distinct_on(self):
+        t = Table('mytable', MetaData(testbase.db),
+                  Column('id', Integer, primary_key=True),
+                  Column('a', String(8)))
+        self.assertEquals(
+            str(t.select(distinct=t.c.a)),
+            'SELECT DISTINCT ON (mytable.a) mytable.id, mytable.a \n'
+            'FROM mytable')
+        self.assertEquals(
+            str(t.select(distinct=['id','a'])),
+            'SELECT DISTINCT ON (id, a) mytable.id, mytable.a \n'
+            'FROM mytable')
+        self.assertEquals(
+            str(t.select(distinct=[t.c.id, t.c.a])),
+            'SELECT DISTINCT ON (mytable.id, mytable.a) mytable.id, mytable.a \n'
+            'FROM mytable')
+
     @testing.supported('postgres')
     def test_schema_reflection(self):
         """note: this test requires that the 'alt_schema' schema be separate and accessible by the test user"""