public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM6780]: While inheriting table, if newly added column present in parent table then merge columns
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][RM6780]: While inheriting table, if newly added column present in parent table then merge columns
@ 2021-10-19 09:01 Pradip Parkale <[email protected]>
  2021-10-21 05:45 ` Re: [pgAdmin][RM6780]: While inheriting table, if newly added column present in parent table then merge columns Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Pradip Parkale @ 2021-10-19 09:01 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

Please find the attached patch  which resolved #6780 While inheriting
table, if newly added column present in parent table then merge columns.

-- 
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation


Attachments:

  [application/octet-stream] RM6780.patch (2.2K, 3-RM6780.patch)
  download | inline diff:
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();


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin][RM6780]: While inheriting table, if newly added column present in parent table then merge columns
  2021-10-19 09:01 [pgAdmin][RM6780]: While inheriting table, if newly added column present in parent table then merge columns Pradip Parkale <[email protected]>
@ 2021-10-21 05:45 ` Akshay Joshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2021-10-21 05:45 UTC (permalink / raw)
  To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers

Thanks, the patch applied.

On Tue, Oct 19, 2021 at 2:31 PM Pradip Parkale <
[email protected]> wrote:

> Hi Hackers,
>
> Please find the attached patch  which resolved #6780 While inheriting
> table, if newly added column present in parent table then merge columns.
>
> --
> Thanks & Regards,
> Pradip Parkale
> Software Engineer | EnterpriseDB Corporation
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-10-21 05:45 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 09:01 [pgAdmin][RM6780]: While inheriting table, if newly added column present in parent table then merge columns Pradip Parkale <[email protected]>
2021-10-21 05:45 ` Akshay Joshi <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox