Skip to content

Commit

Permalink
fix: dont add useless distinct clause
Browse files Browse the repository at this point in the history
confuses query planner in some cases

(cherry picked from commit ae649aa)

# Conflicts:
#	frappe/desk/reportview.py
  • Loading branch information
ankush authored and mergify[bot] committed Mar 12, 2024
1 parent 785b5c2 commit 8891e8e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion frappe/desk/reportview.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
from frappe.model.base_document import get_controller
from frappe.model.db_query import DatabaseQuery
from frappe.model.utils import is_virtual_doctype
<<<<<<< HEAD
from frappe.utils import add_user_info, format_duration
=======
from frappe.utils import add_user_info, cint, format_duration
from frappe.utils.data import sbool
>>>>>>> ae649aadf0 (fix: dont add useless distinct clause)


@frappe.whitelist()
Expand Down Expand Up @@ -53,7 +58,8 @@ def get_count() -> int:
controller = get_controller(args.doctype)
data = controller.get_count(args)
else:
distinct = "distinct " if args.distinct == "true" else ""
args.distinct = sbool(args.distinct)
distinct = "distinct " if args.distinct else ""
args.fields = [f"count({distinct}`tab{args.doctype}`.name) as total_count"]
data = execute(**args)[0].get("total_count")

Expand Down

0 comments on commit 8891e8e

Please sign in to comment.