[minor] frappe.db.table_exists

This commit is contained in:
Rushabh Mehta 2015-03-20 14:12:00 +05:30
parent 38c6f63771
commit aa0bb09dab
2 changed files with 5 additions and 2 deletions

View file

@ -150,7 +150,7 @@ class DocType(Document):
return
# check if atleast 1 record exists
if not (frappe.db.table_exists("tab" + self.name) and frappe.db.sql("select name from `tab{}` limit 1".format(self.name))):
if not (frappe.db.table_exists(self.name) and frappe.db.sql("select name from `tab{}` limit 1".format(self.name))):
return
existing_property_setter = frappe.db.get_value("Property Setter", {"doc_type": self.name,

View file

@ -650,7 +650,10 @@ class Database:
def table_exists(self, tablename):
"""Returns True if table exists."""
return tablename in [d[0] for d in self.sql("show tables")]
return ("tab" + tablename) in self.get_tables()
def get_tables(self):
return [d[0] for d in self.sql("show tables")]
def a_row_exists(self, doctype):
"""Returns True if atleast one row exists."""