From 2162f0983de0dfe2178531638ce7ea56f54dd4e7 Mon Sep 17 00:00:00 2001 From: Matthew Wilkes Date: Sun, 18 Jun 2017 16:53:40 +0100 Subject: Fixed #24747 -- Allowed transforms in QuerySet.order_by() and distinct(*fields). --- django/db/backends/postgresql/operations.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'django/db/backends/postgresql') diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index 3b71cd4f2c..6f48cfa228 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -207,11 +207,12 @@ class DatabaseOperations(BaseDatabaseOperations): """ return 63 - def distinct_sql(self, fields): + def distinct_sql(self, fields, params): if fields: - return 'DISTINCT ON (%s)' % ', '.join(fields) + params = [param for param_list in params for param in param_list] + return (['DISTINCT ON (%s)' % ', '.join(fields)], params) else: - return 'DISTINCT' + return ['DISTINCT'], [] def last_executed_query(self, cursor, sql, params): # http://initd.org/psycopg/docs/cursor.html#cursor.query -- cgit v1.3