From a8bc0f502f92043df72ff9d19dcdcfd9c6bd655e Mon Sep 17 00:00:00 2001 From: Arash Date: Tue, 22 Jun 2021 17:33:52 -0400 Subject: [PATCH] revisions --- .../CRUD/data/database/DatabaseModal/index.tsx | 2 +- superset-frontend/src/views/CRUD/hooks.ts | 13 +++++-------- superset/db_engine_specs/base.py | 3 ++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx index b7305a31a33c7..86699fe2b2759 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -418,7 +418,7 @@ const DatabaseModal: FunctionComponent = ({ }); } setLoading(true); - await getValidation(db, true); + await getValidation(db); const dbId = await createResource(update as DatabaseObject); if (dbId) { setHasConnectedDb(true); diff --git a/superset-frontend/src/views/CRUD/hooks.ts b/superset-frontend/src/views/CRUD/hooks.ts index 25180ee7c21c0..3132422d841c9 100644 --- a/superset-frontend/src/views/CRUD/hooks.ts +++ b/superset-frontend/src/views/CRUD/hooks.ts @@ -638,7 +638,7 @@ export function useDatabaseValidation() { null, ); const getValidation = useCallback( - (database: Partial | null, checkParams?: boolean) => { + (database: Partial | null) => { SupersetClient.post({ endpoint: '/api/v1/database/validate_parameters', body: JSON.stringify(database), @@ -648,14 +648,13 @@ export function useDatabaseValidation() { setValidationErrors(null); }) .catch(e => { - console.log('check Params', checkParams); if (typeof e.json === 'function') { e.json().then(({ errors = [] }: JsonObject) => { const parsedErrors = errors - // .filter( - // (error: { error_type: string }) => - // error.error_type !== 'CONNECTION_MISSING_PARAMETERS_ERROR', - // ) + .filter( + (error: { error_type: string }) => + error.error_type !== 'CONNECTION_MISSING_PARAMETERS_ERROR', + ) .reduce( ( obj: {}, @@ -677,9 +676,7 @@ export function useDatabaseValidation() { }, {}, ); - console.log(parsedErrors); setValidationErrors(parsedErrors); - console.log(validationErrors); }); } else { // eslint-disable-next-line no-console diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py index 314f1070aeb65..943ebc42b73db 100644 --- a/superset/db_engine_specs/base.py +++ b/superset/db_engine_specs/base.py @@ -1441,6 +1441,7 @@ def validate_parameters( ), ) return errors + port = parameters.get("port", None) if not port: return errors @@ -1449,7 +1450,7 @@ def validate_parameters( except (ValueError, TypeError): errors.append( SupersetError( - message="Port must be a valid integer", + message="Port must be a valid integer.", error_type=SupersetErrorType.CONNECTION_INVALID_PORT_ERROR, level=ErrorLevel.ERROR, extra={"invalid": ["port"]},