Skip to content

Commit

Permalink
additional params to the DatabaseConnectionForm (#15071)
Browse files Browse the repository at this point in the history
* additional params to the DatabaseConnectionForm

* save passing params up to api
  • Loading branch information
hughhhh authored Jun 9, 2021
1 parent c2213fc commit a95e416
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export const FormFieldOrder = [
'username',
'password',
'database_name',
'query',
'encryption',
'credentials_info',
'query',
];

interface FieldPropTypes {
Expand Down Expand Up @@ -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"
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
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);
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/views/CRUD/data/database/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type DatabaseObject = {
username?: string;
password?: string;
encryption?: boolean;
query?: string;
};
configuration_method: CONFIGURATION_METHOD;
engine?: string;
Expand Down

0 comments on commit a95e416

Please sign in to comment.