mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user