mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
feat: add support for comments in adhoc clauses (#19248)
* feat: add support for comments in adhoc clauses
* sanitize remaining freeform clauses
* sanitize adhoc having in frontend
* address review comment
(cherry picked from commit f341025d80)
This commit is contained in:
committed by
Ville Brofeldt
parent
f6346d627b
commit
408573d4d6
@@ -30,7 +30,7 @@ from superset.exceptions import (
|
||||
QueryClauseValidationException,
|
||||
QueryObjectValidationError,
|
||||
)
|
||||
from superset.sql_parse import validate_filter_clause
|
||||
from superset.sql_parse import sanitize_clause
|
||||
from superset.superset_typing import Column, Metric, OrderBy
|
||||
from superset.utils import pandas_postprocessing
|
||||
from superset.utils.core import (
|
||||
@@ -272,7 +272,7 @@ class QueryObject: # pylint: disable=too-many-instance-attributes
|
||||
try:
|
||||
self._validate_there_are_no_missing_series()
|
||||
self._validate_no_have_duplicate_labels()
|
||||
self._validate_filters()
|
||||
self._sanitize_filters()
|
||||
return None
|
||||
except QueryObjectValidationError as ex:
|
||||
if raise_exceptions:
|
||||
@@ -291,12 +291,14 @@ class QueryObject: # pylint: disable=too-many-instance-attributes
|
||||
)
|
||||
)
|
||||
|
||||
def _validate_filters(self) -> None:
|
||||
def _sanitize_filters(self) -> None:
|
||||
for param in ("where", "having"):
|
||||
clause = self.extras.get(param)
|
||||
if clause:
|
||||
try:
|
||||
validate_filter_clause(clause)
|
||||
sanitized_clause = sanitize_clause(clause)
|
||||
if sanitized_clause != clause:
|
||||
self.extras[param] = sanitized_clause
|
||||
except QueryClauseValidationException as ex:
|
||||
raise QueryObjectValidationError(ex.message) from ex
|
||||
|
||||
|
||||
Reference in New Issue
Block a user