EnxDev commented on code in PR #45175:
URL: https://github.com/apache/superset/pull/45175#discussion_r4431273700
##########
superset/commands/datasource/list.py:
##########
@@ -298,63 +384,83 @@ def _apply_sql_null_filter(
return type_filter, sql_filter
@staticmethod
- def _parse_filters(
- filters: list[dict[str, Any]],
- ) -> tuple[
- str, str | None, bool | None, str | None, int | None, str | None, str
| None
- ]:
+ def _parse_legacy_filter(
+ col: str, opr: Any, value: Any, current: dict[str, Any]
+ ) -> dict[str, Any]:
+ """Parse the columns the combined list has filtered on from the start.
+
+ An operator other than the one the column is applied with, or a value
+ that cannot be read, raises instead of being dropped: a dropped filter
+ returns an unfiltered list that looks filtered. A ``None`` value is
+ "no filter", as the Datasets page never sends one. ``current`` carries
+ the fields parsed so far, for the ``sql`` filter that updates two of
+ them at once.
"""
- Translate raw rison filter dicts into typed query parameters.
-
- Returns:
- source_type: "all" | "database" | "semantic_layer"
- name_filter: substring to match against name/table_name
- sql_filter: True → physical only, False → virtual only,
None → both
- type_filter: "semantic_view" when caller wants only
- semantic views
- database_id: filter datasets to a specific database ID
- semantic_layer_uuid: filter semantic views to a specific semantic
layer UUID
- schema_filter: filter datasets to a specific schema name
+ if opr != _LEGACY_OPERATORS[col]:
+ raise ValueError(f"Filter operation: {opr} not allowed on column:
{col}")
+ if col == "source_type":
+ return {"source_type": value or "all"}
+ if value is None:
+ return {}
+ if col == "table_name":
+ return {"name_filter": value}
Review Comment:
`table_name` still takes whatever value comes in, so `value:5` or a list
reaches `_escape_ilike_fragment` and fails on `.replace` with a 500 instead of
the 400 this now promises. `semantic_layer_uuid` at line 419 has the same gap:
a non-UUID string only fails when it's bound to the `UUIDType` column.
Could both get the same `Invalid value for filter column` check as
`database`, with a row each in
`test_parse_filters_rejects_malformed_values_on_known_columns`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]