summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 909d568a7..e94f9913c 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1658,23 +1658,20 @@ class PGCompiler(compiler.SQLCompiler):
return "ONLY " + sqltext
def get_select_precolumns(self, select, **kw):
- if select._distinct is not False:
- if select._distinct is True:
- return "DISTINCT "
- elif isinstance(select._distinct, (list, tuple)):
+ if select._distinct or select._distinct_on:
+ if select._distinct_on:
return (
"DISTINCT ON ("
+ ", ".join(
- [self.process(col, **kw) for col in select._distinct]
+ [
+ self.process(col, **kw)
+ for col in select._distinct_on
+ ]
)
+ ") "
)
else:
- return (
- "DISTINCT ON ("
- + self.process(select._distinct, **kw)
- + ") "
- )
+ return "DISTINCT "
else:
return ""