From: Jason Kirtland Date: Wed, 22 Aug 2007 07:33:03 +0000 (+0000) Subject: Added a test for the SELECT DISTINCT ON postgresqlism. X-Git-Tag: rel_0_4beta4~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f981981235d512d892c1619cc6f7561ac3461d2e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Added a test for the SELECT DISTINCT ON postgresqlism. 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. --- diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index 221f7660a9..c12115c9ae 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -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"""