From c79febf40352818ced4e3985cc9baa22fbb922df Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 23 Jun 2026 17:17:38 +0530 Subject: [PATCH] fix(projects): drop redundant distinct from portal project list (Postgres ordering) (#56362) get_project_list builds a single-table query (no joins) with fields="*", which always selects the unique PK `name`, so distinct=True can never deduplicate any rows. It is a no-op on the result set for both engines. It is not a no-op on ordering, though: frappe.db drops the ORDER BY clause for distinct queries on Postgres (Postgres requires every ORDER BY term to appear in the select list under DISTINCT), so the website project list came back unordered on Postgres while MariaDB returned it ordered by `order_by`. Removing the redundant flag leaves the MariaDB result and order untouched and restores the same ordering on Postgres. --- erpnext/projects/doctype/project/project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index f5f06685f53..037e46de78f 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -486,6 +486,8 @@ def get_project_list(doctype, txt, filters, limit_start, limit_page_length=20, o else: filters.append([doctype, "name", "like", "%" + txt + "%"]) + # No distinct=True: it never dedupes here (single table, fields="*" carries PK `name`) but makes + # frappe drop ORDER BY on Postgres, leaving the portal list unordered there. return frappe.get_list( doctype, fields="*", @@ -495,7 +497,6 @@ def get_project_list(doctype, txt, filters, limit_start, limit_page_length=20, o limit_page_length=limit_page_length, order_by=order_by, ignore_permissions=ignore_permissions, - distinct=True, )