ソースを参照

Merge pull request #18225 from frappe/mergify/bp/version-14-hotfix/pr-18219

fix: remove mariadb specific comments from column (backport #18219)
version-14
Ankush Menat 2年前
committed by GitHub
コミット
9d58593da9
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 4AEE18F83AFDEB23
2個のファイルの変更7行の追加2行の削除
  1. +1
    -1
      frappe/utils/__init__.py
  2. +6
    -1
      frappe/utils/data.py

+ 1
- 1
frappe/utils/__init__.py ファイルの表示

@@ -459,7 +459,7 @@ def get_site_base_path():


def get_site_path(*path):
return get_path(base=get_site_base_path(), *path)
return get_path(*path, base=get_site_base_path())


def get_files_path(*path, **kwargs):


+ 6
- 1
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):
@@ -1809,8 +1810,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",
@@ -1826,6 +1830,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


読み込み中…
キャンセル
保存