fix(query): extend regex for allow backticked aliases
For example: ``` `tabSerial and Batch Entry`.`name` as `child_row` ``` Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
bd84d7a66a
commit
2c15bb4a5b
2 changed files with 4 additions and 2 deletions
|
|
@ -59,7 +59,8 @@ def _is_function_call(field_str: str) -> bool:
|
|||
# - `tabTable-Field`.`field` (hyphens in table name)
|
||||
# - Any of above with aliases: ... as alias
|
||||
ALLOWED_FIELD_PATTERN = re.compile(
|
||||
r"^(?:(`[\w\s-]+`|\w+)\.)?(`[\w\s-]+`|\w+)(?:\s+as\s+\w+)?$", flags=re.ASCII | re.IGNORECASE
|
||||
r"^(?:(`[\w\s-]+`|\w+)\.)?(`[\w\s-]+`|\w+)(?:\s+as\s+(?:`[\w\s-]+`|\w+))?$",
|
||||
flags=re.ASCII | re.IGNORECASE,
|
||||
)
|
||||
|
||||
# Regex to parse field names:
|
||||
|
|
|
|||
|
|
@ -153,7 +153,9 @@ class TestQuery(IntegrationTestCase):
|
|||
"`tabUser`.`name` as alias",
|
||||
"*",
|
||||
"`tabHas Role`.`name`",
|
||||
"field as `alias with space`",
|
||||
]
|
||||
|
||||
invalid_fields = [
|
||||
"name; DROP TABLE users",
|
||||
"`name` ; SELECT * FROM secrets",
|
||||
|
|
@ -166,7 +168,6 @@ class TestQuery(IntegrationTestCase):
|
|||
"field with space",
|
||||
"`field with space`",
|
||||
"field as alias with space",
|
||||
"field as `alias with space`",
|
||||
"COUNT(*)",
|
||||
"COUNT(name)",
|
||||
"SUM(amount) as total",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue