mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-25 13:03:02 +00:00
fix(edi): make Common Code docname lookup valid on Postgres
get_docnames_for issued SELECT DISTINCT on Dynamic Link.link_name while ordering by Dynamic Link.idx, a column absent from the select list. This is a raw frappe.qb query (run via .run(), not get_all/get_list), so the ORDER BY is emitted verbatim and PostgreSQL rejects it: 'for SELECT DISTINCT, ORDER BY expressions must appear in select list'. Order by link_name (the selected, distinct column) instead; same docnames on both engines, now deterministically ordered.
This commit is contained in:
@@ -116,7 +116,7 @@ def get_docnames_for(code_list: str, doctype: str, code: str) -> tuple[str]:
|
||||
& (CommonCode.code_list == code_list)
|
||||
)
|
||||
.distinct()
|
||||
.orderby(DynamicLink.idx)
|
||||
.orderby(DynamicLink.link_name)
|
||||
).run()
|
||||
|
||||
return tuple(d[0] for d in docnames) if docnames else ()
|
||||
|
||||
Reference in New Issue
Block a user