Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,14 @@ export default class StatisticsSchema extends BaseUISchema {
},
helpMessage: gettext('Select at least two columns, or one column alongside an expression.'),
// The columns chosen belong to the old table, whatever it changes to.
depChange: () => ({ columns: [] }),
// A field listens to its own changes too, so ignore those, else
// picking a column would immediately clear the selection.
depChange: (state, source) => {
const changed = source?.[source.length - 1];
if (changed === 'schema' || changed === 'table') {
return { columns: [] };
Comment thread
kundansable marked this conversation as resolved.
Resolved
}
},
},
{
id: 'stat_types',
Expand Down
11 changes: 11 additions & 0 deletions web/regression/javascript/schema_ui_files/statistics.ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ describe('StatisticsSchema', () => {
expect(getTables).toHaveBeenCalledWith(16400);
});

it('columns are kept when picked and cleared when the table context changes', () => {
const columns = schemaObj.baseFields.find((f) => f.id == 'columns');
const state = {columns: ['col1', 'col2']};

// A field listens to its own changes, which must not reset it.
expect(columns.depChange(state, ['columns'])).toBeUndefined();

expect(columns.depChange(state, ['schema'])).toEqual({columns: []});
expect(columns.depChange(state, ['table'])).toEqual({columns: []});
});

it('name is required before PostgreSQL 16 and optional from 16', () => {
const nameField = (obj) => obj.baseFields.find((f) => f.id == 'name');

Expand Down
Loading