fix: ensure numeric values for extra metadata_cache_timeout payloads (#28737)

This commit is contained in:
Kidus Makonnen
2025-06-16 23:02:18 +03:00
committed by GitHub
parent d15b0e4f6d
commit 4d6cdf4fea
2 changed files with 8 additions and 9 deletions

View File

@@ -1727,40 +1727,40 @@ describe('dbReducer', () => {
test('it will set state to payload from extra input change when schema_cache_timeout', () => {
const action: DBReducerActionType = {
type: ActionType.ExtraInputChange,
payload: { name: 'schema_cache_timeout', value: 'bar' },
payload: { name: 'schema_cache_timeout', value: '10' },
};
const currentState = dbReducer(databaseFixture, action);
// extra should be serialized
expect(currentState).toEqual({
...databaseFixture,
extra: '{"metadata_cache_timeout":{"schema_cache_timeout":"bar"}}',
extra: '{"metadata_cache_timeout":{"schema_cache_timeout":10}}',
});
});
test('it will set state to payload from extra input change when table_cache_timeout', () => {
const action: DBReducerActionType = {
type: ActionType.ExtraInputChange,
payload: { name: 'table_cache_timeout', value: 'bar' },
payload: { name: 'table_cache_timeout', value: '10' },
};
const currentState = dbReducer(databaseFixture, action);
// extra should be serialized
expect(currentState).toEqual({
...databaseFixture,
extra: '{"metadata_cache_timeout":{"table_cache_timeout":"bar"}}',
extra: '{"metadata_cache_timeout":{"table_cache_timeout":10}}',
});
});
test('it will overwrite state to payload from extra input change when table_cache_timeout', () => {
const action: DBReducerActionType = {
type: ActionType.ExtraInputChange,
payload: { name: 'table_cache_timeout', value: 'bar' },
payload: { name: 'table_cache_timeout', value: '10' },
};
const currentState = dbReducer(
{
...databaseFixture,
extra: '{"metadata_cache_timeout":{"table_cache_timeout":"foo"}}',
extra: '{"metadata_cache_timeout":{"table_cache_timeout":5}}',
},
action,
);
@@ -1768,7 +1768,7 @@ describe('dbReducer', () => {
// extra should be serialized
expect(currentState).toEqual({
...databaseFixture,
extra: '{"metadata_cache_timeout":{"table_cache_timeout":"bar"}}',
extra: '{"metadata_cache_timeout":{"table_cache_timeout":10}}',
});
});

View File

@@ -286,7 +286,6 @@ export function dbReducer(
}),
};
case ActionType.ExtraInputChange:
// "extra" payload in state is a string
if (
action.payload.name === 'schema_cache_timeout' ||
action.payload.name === 'table_cache_timeout'
@@ -297,7 +296,7 @@ export function dbReducer(
...extraJson,
metadata_cache_timeout: {
...extraJson?.metadata_cache_timeout,
[action.payload.name]: action.payload.value,
[action.payload.name]: Number(action.payload.value),
},
}),
};