[pgAdmin4][Patch] - RM 4581 - Can not edit comments of primary key constraint under table node
Khushboo Vashi <[email protected]> Thu, 8 Aug 2019 11:40:56 +0530
| Newsgroups | gmane.comp.db.postgresql.pgadmin.devel |
|---|---|
| Message-ID | <CAFOhELfNYGwqw54aG=qJ5k4cF=AT2-5rJU1rNTy6hXJtZ0YRog@mail.gmail.com> |
Hi, Please find the attached patch to fix the RM #4581 - Can not edit comments of primary key constraint under table node. Thanks, Khushboo
RM_4581.patch
(application/octet-stream, 2 KB)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/update.sql
index 66185329..abc064e7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/default/update.sql
@@ -1,7 +1,7 @@
{### SQL to update constraint object ###}
{% if data %}
{# ==== To update constraint name ==== #}
-{% if data.name != o_data.name %}
+{% if data.name and data.name != o_data.name %}
ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
RENAME CONSTRAINT {{ conn|qtIdent(o_data.name) }} TO {{ conn|qtIdent(data.name) }};
{% endif %}
@@ -19,4 +19,4 @@ ALTER INDEX {{ conn|qtIdent(data.schema, data.name) }}
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
IS {{ data.comment|qtLiteral }};
{% endif %}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
index 5689bc2c..c845806a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
@@ -1325,6 +1325,10 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
return internal_server_error(errormsg=res)
old_data = res['rows'][0]
+
+ # If changes are from table node
+ if 'name' not in c:
+ c['name'] = old_data['name']
# Sql to update object
sql.append(
render_template("/".join([