diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx index 2cc9fbe1a87..1f52d773b48 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx @@ -2134,6 +2134,41 @@ describe('dbReducer', () => { }); }); + // Regression test for https://github.com/apache/superset/issues/30504 + // When creating a database, the POST response doesn't include engine_information, + // but it should be preserved from the initial state set by DbSelected action. + test('it preserves engine_information when Fetched action payload lacks it', () => { + const initialState = { + database_name: 'TestDB', + engine: 'postgresql', + configuration_method: 'sqlalchemy_form' as const, + engine_information: { + supports_file_upload: true, + disable_ssh_tunneling: false, + }, + }; + + // Simulate POST response that doesn't include engine_information + const action: DBReducerActionType = { + type: ActionType.Fetched, + payload: { + id: 123, + database_name: 'TestDB', + backend: 'postgresql', + configuration_method: 'sqlalchemy_form', + // Note: engine_information is NOT in POST response + }, + }; + + const currentState = dbReducer(initialState, action); + + // engine_information should be preserved from initialState + expect(currentState.engine_information).toEqual({ + supports_file_upload: true, + disable_ssh_tunneling: false, + }); + }); + test('it will add a SSH Tunnel config parameter', () => { const action: DBReducerActionType = { type: ActionType.ParametersSSHTunnelChange, diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.tsx index 7b0834077e5..8357349de3b 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/index.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/index.tsx @@ -544,6 +544,10 @@ export function dbReducer( catalog: payloadCatalog, }, // eslint-disable-next-line camelcase + engine_information: + action.payload.engine_information || + trimmedState.engine_information, + // eslint-disable-next-line camelcase query_input, }; } @@ -555,6 +559,9 @@ export function dbReducer( parameters: action.payload.parameters || trimmedState.parameters, ssh_tunnel: action.payload.ssh_tunnel || trimmedState.ssh_tunnel, // eslint-disable-next-line camelcase + engine_information: + action.payload.engine_information || trimmedState.engine_information, + // eslint-disable-next-line camelcase query_input, };