[minor] frappe.db.table_exists
This commit is contained in:
parent
38c6f63771
commit
aa0bb09dab
2 changed files with 5 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue