pgadmin4 icon indicating copy to clipboard operation
pgadmin4 copied to clipboard

ERD Tool - Primary key constraints is not updated after the checkbox for primary key is unchecked

Open petkorutesic opened this issue 9 months ago • 1 comments

Changing a primary key constraints or even deleting attributes does not change the constraints in the "Constraints" tab

Removing an attribute does not change the constraints defined on that attribute.

To Reproduce

Steps to reproduce the behavior:

  1. Define the primary key constraint on a table and save the whole project in the ERD Tool.

  2. Double-click on the table in the diagram, and the form for editing table properties will open. The checkbox for the primary key can now be unchecked. However, saving your changes does not exclude the primary key constraints. The primary key constraint can still be found if you open the "Constraints" tab. Moreover, even if we completely remove the attribute on which the primary constraint is defined, the constraint still remains in the "Constraints" tab.

  3. This can cause problems and is annoying if you click on the "Generate SQL" option which generates SQL DDL statements with unwanting constraints or constraints on unexisting attributes.

Expected behavior

It would be natural that the ERD Tools shows a dialogue form to confirm an automatic delete of the primary key constraint if this constraint is removed in the tab "Columns" that contains the list of attributes.

Screenshots

Screenshot 2024-05-15 at 12 52 23

After we remove the attribute with the primary key: Screenshot 2024-05-15 at 13 48 23

However, the constraint is still there: Screenshot 2024-05-15 at 13 33 12

Error message if the generated DDL SQL is run

Screenshot 2024-05-15 at 13 53 17

Software

  • MacOS: [OSX Sonoma 14.5 - macOS-14.5-x86_64-i386-64bit]
  • pgAdmin4 Version: 8.6 NW.js Version: 0.77.0
  • Mode: Desktop
  • Browser: Chromium 114.0.5735.91

petkorutesic avatar May 15 '24 11:05 petkorutesic

I can confirm its a bug.

adityatoshniwal avatar May 16 '24 03:05 adityatoshniwal

I found same issues with Foreign key, Unique and Exclude constraint in Table dialog as well as in ERD tool table dialog. So fixed all the issues for all the constraints except Check constraint.

While testing this please consider looking into the other constraints also.

anilsahoo20 avatar Jun 13 '24 10:06 anilsahoo20

Issue fixed. Verified on snapshot build.

Env: OS - macOS Sonoma 14.5 Mode - Desktop

pravesh-sharma avatar Jun 19 '24 07:06 pravesh-sharma