You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jo...@apache.org on 2022/10/13 21:26:05 UTC
[superset] branch master updated: fix(explore): Persist URL params to form-data (#21792)
This is an automated email from the ASF dual-hosted git repository.
johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new b1bf25e98c fix(explore): Persist URL params to form-data (#21792)
b1bf25e98c is described below
commit b1bf25e98ceb1a2d52f102d22ebc3631b5278e71
Author: John Bodley <45...@users.noreply.github.com>
AuthorDate: Thu Oct 13 14:25:46 2022 -0700
fix(explore): Persist URL params to form-data (#21792)
---
superset/explore/commands/get.py | 7 ++++---
tests/integration_tests/explore/api_tests.py | 12 ++++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/superset/explore/commands/get.py b/superset/explore/commands/get.py
index 1c56e5540a..331f662767 100644
--- a/superset/explore/commands/get.py
+++ b/superset/explore/commands/get.py
@@ -19,7 +19,7 @@ from abc import ABC
from typing import Any, cast, Dict, Optional
import simplejson as json
-from flask import current_app as app
+from flask import current_app, request
from flask_babel import gettext as __, lazy_gettext as _
from sqlalchemy.exc import SQLAlchemyError
@@ -121,7 +121,7 @@ class GetExploreCommand(BaseCommand, ABC):
dataset_name = dataset.name if dataset else _("[Missing Dataset]")
if dataset:
- if app.config["ENABLE_ACCESS_REQUEST"] and (
+ if current_app.config["ENABLE_ACCESS_REQUEST"] and (
not security_manager.can_access_datasource(dataset)
):
message = __(security_manager.get_datasource_access_error_msg(dataset))
@@ -139,9 +139,10 @@ class GetExploreCommand(BaseCommand, ABC):
str(self._dataset_id) + "__" + cast(str, self._dataset_type)
)
- # On explore, merge legacy and extra filters into the form data
+ # On explore, merge legacy/extra filters and URL params into the form data
utils.convert_legacy_filters_into_adhoc(form_data)
utils.merge_extra_filters(form_data)
+ utils.merge_request_params(form_data, request.args)
dummy_dataset_data: Dict[str, Any] = {
"type": self._dataset_type,
diff --git a/tests/integration_tests/explore/api_tests.py b/tests/integration_tests/explore/api_tests.py
index 8fb642286a..dee7424a09 100644
--- a/tests/integration_tests/explore/api_tests.py
+++ b/tests/integration_tests/explore/api_tests.py
@@ -226,3 +226,15 @@ def test_wrong_endpoint(mock_get_datasource, test_client, login_as_admin, datase
data = json.loads(resp.data.decode("utf-8"))
assert resp.status_code == 302
assert data["redirect"] == dataset.default_endpoint
+
+
+def test_get_url_params(test_client, login_as_admin, chart_id):
+ resp = test_client.get(f"api/v1/explore/?slice_id={chart_id}&foo=bar")
+ assert resp.status_code == 200
+ data = json.loads(resp.data.decode("utf-8"))
+ result = data.get("result")
+
+ assert result["form_data"]["url_params"] == {
+ "foo": "bar",
+ "slice_id": str(chart_id),
+ }