fix: correctly compute doctype name from table name

This commit is contained in:
Ankush Menat 2022-01-24 11:10:03 +05:30
parent 1e70c02e43
commit e58c557e12
3 changed files with 4 additions and 4 deletions

View file

@ -148,7 +148,7 @@ def build_table_count_cache():
data = (
frappe.qb.from_(information_schema.tables).select(table_name, table_rows)
).run(as_dict=True)
counts = {d.get('name').lstrip('tab'): d.get('count', None) for d in data}
counts = {d.get('name').replace('tab', '', 1): d.get('count', None) for d in data}
_cache.set_value("information_schema:counts", counts)
return counts

View file

@ -952,7 +952,7 @@ def trim_database(context, dry_run, format, no_backup):
doctype_tables = frappe.get_all("DocType", pluck="name")
for x in database_tables:
doctype = x.lstrip("tab")
doctype = x.replace("tab", "", 1)
if not (doctype in doctype_tables or x.startswith("__") or x in STANDARD_TABLES):
TABLES_TO_DROP.append(x)
@ -966,7 +966,7 @@ def trim_database(context, dry_run, format, no_backup):
odb = scheduled_backup(
ignore_conf=False,
include_doctypes=",".join(x.lstrip("tab") for x in TABLES_TO_DROP),
include_doctypes=",".join(x.replace("tab", "", 1) for x in TABLES_TO_DROP),
ignore_files=True,
force=True,
)

View file

@ -308,7 +308,7 @@ class Permission:
doctype = [doctype]
for dt in doctype:
dt = re.sub("tab", "", dt)
dt = re.sub("^tab", "", dt)
if not frappe.has_permission(
dt,
"select",