diff --git a/frappe/database/database.py b/frappe/database/database.py index 3b29fd522c..40eb7d8bbd 100644 --- a/frappe/database/database.py +++ b/frappe/database/database.py @@ -789,7 +789,7 @@ class Database: if fields == "*" and not isinstance(fields, (list, tuple)) and not isinstance(fields, Criterion): as_dict = True - return self.sql(query, as_dict=as_dict, debug=debug, update=update, run=run, pluck=pluck) + return query.run(as_dict=as_dict, debug=debug, update=update, run=run, pluck=pluck) def _get_value_for_many_names( self, @@ -806,18 +806,15 @@ class Database: as_dict=False, ): if names := list(filter(None, names)): - return self.get_all( + return frappe.qb.engine.get_query( doctype, fields=field, filters=names, order_by=order_by, pluck=pluck, - debug=debug, - as_list=not as_dict, - run=run, distinct=distinct, - limit_page_length=limit, - ) + limit=limit, + ).run(debug=debug, as_list=not as_dict, run=run) return {} def update(self, *args, **kwargs): @@ -1068,10 +1065,9 @@ class Database: cache_count = frappe.cache().get_value(f"doctype:count:{dt}") if cache_count is not None: return cache_count - query = frappe.qb.engine.get_query( + count = frappe.qb.engine.get_query( table=dt, filters=filters, fields=Count("*"), distinct=distinct - ) - count = self.sql(query, debug=debug)[0][0] + ).run(debug=debug)[0][0] if not filters and cache: frappe.cache().set_value(f"doctype:count:{dt}", count, expires_in_sec=86400) return count