From b524d892f7c60de0477fb306477a0706b4a449c6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 3 Aug 2017 17:02:47 +0530 Subject: [PATCH] Add where clause only if conditions exists (#3853) --- frappe/database.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/database.py b/frappe/database.py index 9b9e9e1446..0f0900678e 100644 --- a/frappe/database.py +++ b/frappe/database.py @@ -600,8 +600,9 @@ class Database: order_by = ("order by " + order_by) if order_by else "" - r = self.sql("select {0} from `tab{1}` where {2} {3}".format(fl, doctype, - conditions, order_by), values, as_dict=as_dict, debug=debug, update=update) + r = self.sql("select {0} from `tab{1}` {2} {3} {4}" + .format(fl, doctype, "where" if conditions else "", conditions, order_by), values, + as_dict=as_dict, debug=debug, update=update) return r