From 51c5a65cdd346455e029a05c1d6dc0a5dcdb6ad1 Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Thu, 19 Feb 2026 13:30:30 -0800 Subject: [PATCH] fix(database): preserve engine_information when creating database connection When creating a new database connection, the "Allow file uploads to database" checkbox was missing. This was because: 1. When selecting a database, engine_information (containing supports_file_upload) was set from the available databases list 2. After creating the database, the POST response was used to update state via the Fetched action 3. The POST response doesn't include engine_information, so the Fetched reducer was overwriting the state and losing it 4. ExtraOptions checks engine_information.supports_file_upload to render the checkbox The fix preserves engine_information from the existing state when the Fetched action payload doesn't include it, following the same pattern used for engine, parameters, and ssh_tunnel fields. Fixes: #30504 Co-Authored-By: Claude Opus 4.5 --- .../databases/DatabaseModal/index.test.tsx | 35 +++++++++++++++++++ .../databases/DatabaseModal/index.tsx | 7 ++++ 2 files changed, 42 insertions(+) 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, };