From 37b9857f4d97d7555cb291da88f7408fc026a394 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 22 Aug 2007 17:53:01 +0000 Subject: - added **modifiers to _get_from_objects - fixed up PG distinct flag --- lib/sqlalchemy/databases/postgres.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib/sqlalchemy/databases/postgres.py') diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 2a4d230cd..e2876f1f8 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -567,15 +567,14 @@ class PGCompiler(compiler.DefaultCompiler): def get_select_precolumns(self, select): if select._distinct: - if type(select._distinct) == bool: + if isinstance(select._distinct, bool): return "DISTINCT " - if type(select._distinct) == list: - dist_set = "DISTINCT ON (" - for col in select._distinct: - dist_set += self.strings[col] + ", " - dist_set = dist_set[:-2] + ") " - return dist_set - return "DISTINCT ON (" + str(select._distinct) + ") " + elif isinstance(select._distinct, (list, tuple)): + return "DISTINCT ON (" + ', '.join( + [(isinstance(col, basestring) and col or self.process(col)) for col in select._distinct] + )+ ") " + else: + return "DISTINCT ON (" + unicode(select._distinct) + ") " else: return "" -- cgit v1.2.1