Skip to content

Commit

Permalink
revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Jun 22, 2021
1 parent ed10ef3 commit a8bc0f5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
});
}
setLoading(true);
await getValidation(db, true);
await getValidation(db);
const dbId = await createResource(update as DatabaseObject);
if (dbId) {
setHasConnectedDb(true);
Expand Down
13 changes: 5 additions & 8 deletions superset-frontend/src/views/CRUD/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ export function useDatabaseValidation() {
null,
);
const getValidation = useCallback(
(database: Partial<DatabaseObject> | null, checkParams?: boolean) => {
(database: Partial<DatabaseObject> | null) => {
SupersetClient.post({
endpoint: '/api/v1/database/validate_parameters',
body: JSON.stringify(database),
Expand All @@ -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: {},
Expand All @@ -677,9 +676,7 @@ export function useDatabaseValidation() {
},
{},
);
console.log(parsedErrors);
setValidationErrors(parsedErrors);
console.log(validationErrors);
});
} else {
// eslint-disable-next-line no-console
Expand Down
3 changes: 2 additions & 1 deletion superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ def validate_parameters(
),
)
return errors

port = parameters.get("port", None)
if not port:
return errors
Expand All @@ -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"]},
Expand Down

0 comments on commit a8bc0f5

Please sign in to comment.