This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 2dc8bd6 fix: Fix test connection for extra fields (#15645)
2dc8bd6 is described below
commit 2dc8bd6c30ea16f94d1e6d62a557861491c9e123
Author: Hugh A. Miles II <[email protected]>
AuthorDate: Mon Jul 12 20:19:45 2021 -0700
fix: Fix test connection for extra fields (#15645)
* create serialize json function
* remove console.log
* use function
---
.../CRUD/data/database/DatabaseModal/index.tsx | 25 ++++++++++------------
1 file changed, 11 insertions(+), 14 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 54a8cc4..634ad8e 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -316,6 +316,15 @@ function dbReducer(
const DEFAULT_TAB_KEY = '1';
+const serializeExtra = (extraJson: DatabaseObject['extra_json']) =>
+ JSON.stringify({
+ ...extraJson,
+ metadata_params: JSON.parse((extraJson?.metadata_params as string) ||
'{}'),
+ engine_params: JSON.parse((extraJson?.engine_params as string) || '{}'),
+ schemas_allowed_for_csv_upload:
+ (extraJson?.schemas_allowed_for_csv_upload as string) || '[]',
+ });
+
const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
addDangerToast,
addSuccessToast,
@@ -388,7 +397,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps>
= ({
sqlalchemy_uri: db?.sqlalchemy_uri || '',
database_name: db?.database_name?.trim() || undefined,
impersonate_user: db?.impersonate_user || undefined,
- extra: db?.extra || undefined,
+ extra: serializeExtra(db?.extra_json) || undefined,
encrypted_extra: db?.encrypted_extra || '',
server_cert: db?.server_cert || undefined,
};
@@ -460,19 +469,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps>
= ({
if (dbToUpdate?.extra_json) {
// convert extra_json to back to string
- dbToUpdate.extra = JSON.stringify({
- ...dbToUpdate.extra_json,
- metadata_params: JSON.parse(
- (dbToUpdate?.extra_json?.metadata_params as string) || '{}',
- ),
- engine_params: JSON.parse(
- (dbToUpdate?.extra_json?.engine_params as string) || '{}',
- ),
- schemas_allowed_for_csv_upload: JSON.parse(
- (dbToUpdate?.extra_json?.schemas_allowed_for_csv_upload as string) ||
- '[]',
- ),
- });
+ dbToUpdate.extra = serializeExtra(dbToUpdate?.extra_json);
}
if (db?.id) {