Ensure that columns should be merged if the newly added column is present in the parent table. Fixes #6780

This commit is contained in:
Pradip Parkale 2021-10-21 10:59:52 +05:30 committed by Akshay Joshi
parent d2a7f7fffe
commit c7cd57db91
4 changed files with 42 additions and 3 deletions

View File

@ -11,6 +11,7 @@ notes for it.
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
release_notes_6_2
release_notes_6_1 release_notes_6_1
release_notes_6_0 release_notes_6_0
release_notes_5_7 release_notes_5_7

View File

@ -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 <https://redmine.postgresql.org/issues/6780>`_ - Ensure that columns should be merged if the newly added column is present in the parent table.

View File

@ -537,7 +537,24 @@ export default class TableSchema extends BaseUISchema {
tabColsResponse.then((res)=>{ tabColsResponse.then((res)=>{
resolve((state)=>{ resolve((state)=>{
let finalCols = res.map((col)=>obj.columnsSchema.getNewData(col)); 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); obj.changeColumnOptions(finalCols);
return { return {
adding_inherit_cols: false, adding_inherit_cols: false,

View File

@ -277,10 +277,10 @@ describe('TableSchema', ()=>{
}, },
}); });
deferredPromise.then((depChange)=>{ deferredPromise.then((depChange)=>{
let finalCols = [newCol, newCol]; let finalCols = [newCol];
expect(depChange(state)).toEqual({ expect(depChange(state)).toEqual({
adding_inherit_cols: false, adding_inherit_cols: false,
columns: [newCol, newCol], columns: [newCol],
}); });
expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(finalCols); expect(schemaObj.changeColumnOptions).toHaveBeenCalledWith(finalCols);
done(); done();