diff --git a/frappe/public/js/frappe/ui/sort_selector.js b/frappe/public/js/frappe/ui/sort_selector.js index 0ce84c1d5f..6e06f18956 100644 --- a/frappe/public/js/frappe/ui/sort_selector.js +++ b/frappe/public/js/frappe/ui/sort_selector.js @@ -196,12 +196,12 @@ frappe.ui.SortSelector = class SortSelector { } } get_sql_string() { - // build string like: `tabSales Invoice`.subject, `tabSales Invoice`.name desc + // build string like: `tabSales Invoice`.`subject`, `tabSales Invoice`.`name` desc const table_name = "`tab" + this.doctype + "`"; - const sort_by = `${table_name}.${this.sort_by}`; + const sort_by = `${table_name}.\`${this.sort_by}\``; if (!["name", "creation", "modified"].includes(this.sort_by)) { // add name column for deterministic ordering - return `${sort_by} ${this.sort_order}, ${table_name}.name ${this.sort_order}`; + return `${sort_by} ${this.sort_order}, ${table_name}.\`name\` ${this.sort_order}`; } else { return `${sort_by} ${this.sort_order}`; }