Compare commits

...

2 Commits

Author SHA1 Message Date
Evan Rusackas
147e6f6da6 fix(database): use ConfigurationMethod enum and proper typing in test
- Use ConfigurationMethod.SqlalchemyUri instead of string literal
- Add Partial<DatabaseObject> type annotation for initialState
- Add null check before accessing currentState properties

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-22 14:18:02 -08:00
Evan Rusackas
51c5a65cdd 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>
2026-02-22 14:18:02 -08:00
2 changed files with 43 additions and 0 deletions

View File

@@ -2134,6 +2134,42 @@ 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: Partial<DatabaseObject> = {
database_name: 'TestDB',
engine: 'postgresql',
configuration_method: ConfigurationMethod.SqlalchemyUri,
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: ConfigurationMethod.SqlalchemyUri,
// Note: engine_information is NOT in POST response
},
};
const currentState = dbReducer(initialState, action);
// engine_information should be preserved from initialState
expect(currentState).not.toBeNull();
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,

View File

@@ -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,
};