From c7cd57db913f049dab1605e1e1fea3a366837506 Mon Sep 17 00:00:00 2001 From: Pradip Parkale Date: Thu, 21 Oct 2021 10:59:52 +0530 Subject: [PATCH] Ensure that columns should be merged if the newly added column is present in the parent table. Fixes #6780 --- docs/en_US/release_notes.rst | 1 + docs/en_US/release_notes_6_2.rst | 21 +++++++++++++++++++ .../schemas/tables/static/js/table.ui.js | 19 ++++++++++++++++- .../schema_ui_files/table.ui.spec.js | 4 ++-- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 docs/en_US/release_notes_6_2.rst diff --git a/docs/en_US/release_notes.rst b/docs/en_US/release_notes.rst index 6bbbb443a..4b0f2cc31 100644 --- a/docs/en_US/release_notes.rst +++ b/docs/en_US/release_notes.rst @@ -11,6 +11,7 @@ notes for it. .. toctree:: :maxdepth: 1 + release_notes_6_2 release_notes_6_1 release_notes_6_0 release_notes_5_7 diff --git a/docs/en_US/release_notes_6_2.rst b/docs/en_US/release_notes_6_2.rst new file mode 100644 index 000000000..a40f20788 --- /dev/null +++ b/docs/en_US/release_notes_6_2.rst @@ -0,0 +1,21 @@ +************ +Version 6.2 +************ + +Release date: 2021-11-18 + +This release contains a number of bug fixes and new features since the release of pgAdmin4 6.1. + +New features +************ + + + +Housekeeping +************ + + +Bug fixes +********* + +| `Issue #6780 `_ - Ensure that columns should be merged if the newly added column is present in the parent table. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js index a8e1b8cca..f8127cc3f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js @@ -537,7 +537,24 @@ export default class TableSchema extends BaseUISchema { tabColsResponse.then((res)=>{ resolve((state)=>{ let finalCols = res.map((col)=>obj.columnsSchema.getNewData(col)); - finalCols = [...state.columns, ...finalCols]; + let currentSelectedCols = []; + if (!_.isEmpty(state.columns)){ + currentSelectedCols = state.columns; + } + let colNameList = []; + state.columns.forEach((col=>{ + colNameList.push(col.name); + })); + for (let col of Object.values(finalCols)) { + if(!colNameList.includes(col.name)){ + currentSelectedCols.push(col); + } + } + + if (!_.isEmpty(currentSelectedCols)){ + finalCols = currentSelectedCols; + } + obj.changeColumnOptions(finalCols); return { adding_inherit_cols: false, diff --git a/web/regression/javascript/schema_ui_files/table.ui.spec.js b/web/regression/javascript/schema_ui_files/table.ui.spec.js index 0ddf9accd..c225c532b 100644 --- a/web/regression/javascript/schema_ui_files/table.ui.spec.js +++ b/web/regression/javascript/schema_ui_files/table.ui.spec.js @@ -277,10 +277,10 @@ describe('TableSchema', ()=>{ }, }); deferredPromise.then((depChange)=>{ - let finalCols = [newCol, newCol]; + let finalCols = [newCol]; expect(depChange(state)).toEqual({ adding_inherit_cols: false, - columns: [newCol, newCol], + columns: [newCol], }); expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(finalCols); done();