pgadmin4
pgadmin4 copied to clipboard
ERD Tool - Primary key constraints is not updated after the checkbox for primary key is unchecked
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:
-
Define the primary key constraint on a table and save the whole project in the ERD Tool.
-
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.
-
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
After we remove the attribute with the primary key:
However, the constraint is still there:
Error message if the generated DDL SQL is run
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
I can confirm its a bug.
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.