diff --git a/frappe/utils/data.py b/frappe/utils/data.py index 9f794be0fc..8f0065b04c 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -45,6 +45,7 @@ URL_NOTATION_PATTERN = re.compile( ) # background-image: url('/assets/...') DURATION_PATTERN = re.compile(r"^(?:(\d+d)?((^|\s)\d+h)?((^|\s)\d+m)?((^|\s)\d+s)?)$") HTML_TAG_PATTERN = re.compile("<[^>]+>") +MARIADB_SPECIFIC_COMMENT = re.compile(r"#.*") class Weekday(Enum): @@ -1827,8 +1828,11 @@ def sanitize_column(column_name: str) -> None: from frappe import _ - regex = re.compile("^.*[,'();].*") column_name = sqlparse.format(column_name, strip_comments=True, keyword_case="lower") + if frappe.db and frappe.db.db_type == "mariadb": + # strip mariadb specific comments which are like python single line comments + column_name = MARIADB_SPECIFIC_COMMENT.sub("", column_name) + blacklisted_keywords = [ "select", "create", @@ -1844,6 +1848,7 @@ def sanitize_column(column_name: str) -> None: def _raise_exception(): frappe.throw(_("Invalid field name {0}").format(column_name), frappe.DataError) + regex = re.compile("^.*[,'();].*") if "ifnull" in column_name: if regex.match(column_name): # to avoid and, or