diff --git a/frappe/database/database.py b/frappe/database/database.py index 6702ce2a5e..412051c76f 100644 --- a/frappe/database/database.py +++ b/frappe/database/database.py @@ -758,7 +758,10 @@ class Database(object): def field_exists(self, dt, fn): """Return true of field exists.""" - return self.sql("select name from tabDocField where fieldname=%s and parent=%s", (dt, fn)) + return self.exists('DocField', { + 'fieldname': fn, + 'parent': dt + }) def table_exists(self, doctype): """Returns True if table for given doctype exists.""" diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index 7480970711..6eb2efce6b 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -38,8 +38,8 @@ def get_controller(doctype): or ["Core", False] if custom: - if frappe.db.field_exists(doctype, "is_tree"): - is_tree = frappe.db.get_value("DocType", doctype, ("is_tree"), cache=True) + if frappe.db.field_exists("DocType", "is_tree"): + is_tree = frappe.db.get_value("DocType", doctype, "is_tree", cache=True) else: is_tree = False _class = NestedSet if is_tree else Document