perf(orm): Use cached table_columns instead of querying the database

This commit is contained in:
Aditya Hase 2019-09-07 00:48:54 +05:30
parent c7a04add35
commit 10bd8012ce
No known key found for this signature in database
GPG key ID: 2F5E3D5822BBF831

View file

@ -17,6 +17,7 @@ from frappe.model import optional_fields
from frappe.client import check_parent_permission
from frappe.model.utils.user_settings import get_user_settings, update_user_settings
from frappe.utils import flt, cint, get_time, make_filter_tuple, get_filter, add_to_date, cstr, nowdate
from frappe.model.meta import get_table_columns
class DatabaseQuery(object):
def __init__(self, doctype, user=None):
@ -290,7 +291,7 @@ class DatabaseQuery(object):
def set_optional_columns(self):
"""Removes optional columns like `_user_tags`, `_comments` etc. if not in table"""
columns = frappe.db.get_table_columns(self.doctype)
columns = get_table_columns(self.doctype)
# remove from fields
to_remove = []