public inbox for [email protected]  
help / color / mirror / Atom feed
From: Aditya Toshniwal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM7275] Error when creating table in ERD
Date: Wed, 30 Mar 2022 18:14:43 +0530
Message-ID: <CAM9w-_kTSXOv0XcLcDogc2t41kU+aVhb=YjaPKc6cjBfV1_RVw@mail.gmail.com> (raw)

Hi Hackers,

Attached is the patch for the fix.
Please review.

-- 
Thanks,
Aditya Toshniwal
pgAdmin Hacker | Software Architect | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"


Attachments:

  [application/octet-stream] RM7275.patch (1.8K, 3-RM7275.patch)
  download | inline diff:
diff --git a/web/pgadmin/tools/erd/static/js/erd_tool/ERDCore.js b/web/pgadmin/tools/erd/static/js/erd_tool/ERDCore.js
index 5048ffb3c..29f650eb9 100644
--- a/web/pgadmin/tools/erd/static/js/erd_tool/ERDCore.js
+++ b/web/pgadmin/tools/erd/static/js/erd_tool/ERDCore.js
@@ -267,11 +267,12 @@ export default class ERDCore {
     });
   }
 
-  syncTableLinks(tableNode, oldTableData) {
+  syncColDrop(tableNode, oldTableData) {
     let self = this;
+    if(!oldTableData) {
+      return;
+    }
     let tableData = tableNode.getData();
-    const tableNodesDict = this.getModel().getNodesDict();
-
     /* Remove the links if column dropped or primary key removed */
     _.differenceWith(oldTableData.columns, tableData.columns, function(existing, incoming) {
       if(existing.attnum == incoming.attnum && existing.is_primary_key && !incoming.is_primary_key) {
@@ -287,7 +288,13 @@ export default class ERDCore {
       }
       tableNode.removePort(existPort);
     });
+  }
 
+  syncFkRefNames(tableNode, oldTableData) {
+    if(!oldTableData) {
+      return;
+    }
+    let tableData = tableNode.getData();
     /* Sync the name changes in references FK */
     Object.values(tableNode.getPorts()).forEach((port)=>{
       if(port.getSubtype() != 'one') {
@@ -312,9 +319,17 @@ export default class ERDCore {
         });
       });
     });
+  }
 
+  syncTableLinks(tableNode, oldTableData) {
+    if(oldTableData) {
+      this.syncColDrop(tableNode, oldTableData);
+      this.syncFkRefNames(tableNode, oldTableData);
+    }
     /* Sync the changed/removed/added foreign keys */
-    tableData = tableNode.getData();
+    let tableData = tableNode.getData();
+    let tableNodesDict = this.getModel().getNodesDict();
+
     const addLink = (theFk)=>{
       if(!theFk) return;
       let newData = {


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin][RM7275] Error when creating table in ERD
  In-Reply-To: <CAM9w-_kTSXOv0XcLcDogc2t41kU+aVhb=YjaPKc6cjBfV1_RVw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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