refactor: if() to CASE WHEN (#31360)

* refactor: if() to CASE WHEN

* fix: remove duplicate order by

* fix: remove extraneous table

* style: reformat to black spec

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
Conor
2022-06-17 10:47:48 -05:00
committed by GitHub
parent a0cab761b8
commit ea28ed1bb3
6 changed files with 28 additions and 28 deletions

View File

@@ -387,8 +387,8 @@ def get_users_for_project(doctype, txt, searchfield, start, page_len, filters):
or full_name like %(txt)s)
{fcond} {mcond}
order by
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
if(locate(%(_txt)s, full_name), locate(%(_txt)s, full_name), 99999),
(case when locate(%(_txt)s, name) > 0 then locate(%(_txt)s, name) else 99999 end),
(case when locate(%(_txt)s, full_name) > 0 then locate(%(_txt)s, full_name) else 99999 end)
idx desc,
name, full_name
limit %(page_len)s offset %(start)s""".format(