diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx index ab073b13f36e8..d32299c2ed36d 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx @@ -45,9 +45,9 @@ export const FormFieldOrder = [ 'username', 'password', 'database_name', + 'query', 'encryption', 'credentials_info', - 'query', ]; interface FieldPropTypes { @@ -282,10 +282,10 @@ const queryField = ({ value={db?.query} validationMethods={{ onBlur: getValidation }} errorMessage={validationErrors?.query} - placeholder="" + placeholder="e.g. additional parameters" label="Additional Parameters" - onChange={changeMethods.onChange} - helpText="Pick a nickname for this database to display as in Superset." + onChange={changeMethods.onParametersChange} + helpText="Add additional custom parameters" /> ); 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 67ad8ea74a94a..e7b8e4dcf3330 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -282,6 +282,15 @@ const DatabaseModal: FunctionComponent = ({ credentials_info: JSON.parse(update.encrypted_extra), }); } + if (update.parameters.query) { + // convert query params into dictionary + update.parameters.query = JSON.parse( + `{"${decodeURI(db.parameters.query || '') + .replace(/"/g, '\\"') + .replace(/&/g, '","') + .replace(/=/g, '":"')}"}`, + ); + } const dbId = await createResource(update as DatabaseObject); if (dbId) { setHasConnectedDb(true); diff --git a/superset-frontend/src/views/CRUD/data/database/types.ts b/superset-frontend/src/views/CRUD/data/database/types.ts index f611dd76cea97..8c0264116da17 100644 --- a/superset-frontend/src/views/CRUD/data/database/types.ts +++ b/superset-frontend/src/views/CRUD/data/database/types.ts @@ -38,6 +38,7 @@ export type DatabaseObject = { username?: string; password?: string; encryption?: boolean; + query?: string; }; configuration_method: CONFIGURATION_METHOD; engine?: string;