feat: deprecate /superset/validate_sql_json migrate to api v1 (#19935)

* feat: deprecate /superset/validate_sql_json migrate to api v1

* use new error handling

* migrate SQLLAb frontend and add tests

* debug test

* debug test

* fix frontend test on sqllab

* fix tests

* fix frontend test on sqllab

* fix tests

* fix tests

* fix tests

* fix tests
This commit is contained in:
Daniel Vaz Gaspar
2022-05-10 21:25:39 +01:00
committed by GitHub
parent 9376940282
commit 87a4379d0a
9 changed files with 464 additions and 20 deletions

View File

@@ -369,24 +369,19 @@ export function validateQuery(query) {
dispatch(startQueryValidation(query));
const postPayload = {
client_id: query.id,
database_id: query.dbId,
json: true,
schema: query.schema,
sql: query.sql,
sql_editor_id: query.sqlEditorId,
templateParams: query.templateParams,
validate_only: true,
template_params: query.templateParams,
};
return SupersetClient.post({
endpoint: `/superset/validate_sql_json/${window.location.search}`,
postPayload,
stringify: false,
endpoint: `/api/v1/database/${query.dbId}/validate_sql`,
body: JSON.stringify(postPayload),
headers: { 'Content-Type': 'application/json' },
})
.then(({ json }) => dispatch(queryValidationReturned(query, json)))
.then(({ json }) => dispatch(queryValidationReturned(query, json.result)))
.catch(response =>
getClientErrorObject(response).then(error => {
getClientErrorObject(response.result).then(error => {
let message = error.error || error.statusText || t('Unknown error');
if (message.includes('CSRF token')) {
message = t(COMMON_ERR_MESSAGES.SESSION_TIMED_OUT);