fix: correct SQL string formatting in get_sql_string method (#34418)

This commit is contained in:
Bhavesh Maheshwari 2025-10-15 20:54:14 +05:30 committed by GitHub
parent 727775f820
commit 2232ff75c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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}`;
}