perf: Avoid parsing same field repeatedly (#29030)
This commit is contained in:
parent
ff80d378e6
commit
dd6346e466
1 changed files with 7 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ import time
|
|||
import typing
|
||||
from code import compile_command
|
||||
from enum import Enum
|
||||
from functools import lru_cache
|
||||
from typing import Any, Literal, Optional, TypeVar
|
||||
from urllib.parse import parse_qsl, quote, urlencode, urljoin, urlparse, urlunparse
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
|
@ -2107,12 +2108,17 @@ def make_filter_dict(filters):
|
|||
|
||||
|
||||
def sanitize_column(column_name: str) -> None:
|
||||
return _sanitize_column(column_name, (frappe.db and frappe.db.db_type) or None)
|
||||
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
def _sanitize_column(column_name: str, db_type: str) -> None:
|
||||
import sqlparse
|
||||
|
||||
from frappe import _
|
||||
|
||||
column_name = sqlparse.format(column_name, strip_comments=True, keyword_case="lower")
|
||||
if frappe.db and frappe.db.db_type == "mariadb":
|
||||
if db_type == "mariadb":
|
||||
# strip mariadb specific comments which are like python single line comments
|
||||
column_name = MARIADB_SPECIFIC_COMMENT.sub("", column_name)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue