From 7c6fabb033fc68ee94e4c3941fd1e0691ee1a459 Mon Sep 17 00:00:00 2001 From: Daniel Vaz Gaspar Date: Mon, 14 Nov 2022 08:51:26 +0000 Subject: [PATCH] chore: deprecate /superset/fetch_datasource_metadata mig to API v1 (#22102) --- superset-frontend/src/SqlLab/actions/sqlLab.js | 11 ++++++----- superset/datasets/api.py | 1 + superset/views/core.py | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 0da9295b3a02c..0d20f06c9266a 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -1409,17 +1409,18 @@ export function popQuery(queryId) { } export function popDatasourceQuery(datasourceKey, sql) { return function (dispatch) { + const datasetId = datasourceKey.split('__')[0]; return SupersetClient.get({ - endpoint: `/superset/fetch_datasource_metadata?datasourceKey=${datasourceKey}`, + endpoint: `/api/v1/dataset/${datasetId}?q=(keys:!(none))`, }) .then(({ json }) => dispatch( addQueryEditor({ - name: `Query ${json.name}`, - dbId: json.database.id, - schema: json.schema, + name: `Query ${json.result.name}`, + dbId: json.result.database.id, + schema: json.result.schema, autorun: sql !== undefined, - sql: sql || json.select_star, + sql: sql || json.result.select_star, }), ), ) diff --git a/superset/datasets/api.py b/superset/datasets/api.py index 069268a42871e..fd2bd8c5a9154 100644 --- a/superset/datasets/api.py +++ b/superset/datasets/api.py @@ -142,6 +142,7 @@ class DatasetRestApi(BaseSupersetModelRestApi): "cache_timeout", "is_sqllab_view", "template_params", + "select_star", "owners.id", "owners.username", "owners.first_name", diff --git a/superset/views/core.py b/superset/views/core.py index cc1865452a856..f88fc7573f93a 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -2598,6 +2598,11 @@ def fetch_datasource_metadata(self) -> FlaskResponse: # pylint: disable=no-self :returns: The Flask response :raises SupersetSecurityException: If the user cannot access the resource """ + logger.warning( + "%s.fetch_datasource_metadata " + "This API endpoint is deprecated and will be removed in version 3.0.0", + self.__class__.__name__, + ) datasource_id, datasource_type = request.args["datasourceKey"].split("__") datasource = DatasourceDAO.get_datasource(