From 67e5dfa5a77174e2563f2bf1b7a4f8765bed4ca7 Mon Sep 17 00:00:00 2001 From: Murtuza Zabuawala Date: Fri, 28 Oct 2016 16:40:27 +0100 Subject: [PATCH] Fix refreshing of Unique constraints. Fixes #1893 --- .../tables/constraints/index_constraint/__init__.py | 7 +++++++ .../tables/templates/index_constraint/sql/nodes.sql | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py index 399fd06ef..690b24385 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py @@ -398,9 +398,13 @@ class IndexConstraintView(PGChildNodeView): """ SQL = render_template("/".join([self.template_path, 'nodes.sql']), cid=cid, + tid=tid, constraint_type=self.constraint_type) status, rset = self.conn.execute_2darray(SQL) + if not status: + return internal_server_error(errormsg=rset) + if len(rset['rows']) == 0: return gone(_("""Could not find the {} in the table.""".format( "primary key" if self.constraint_type == "p" else "unique key" @@ -439,6 +443,9 @@ class IndexConstraintView(PGChildNodeView): constraint_type=self.constraint_type) status, rset = self.conn.execute_2darray(SQL) + if not status: + return internal_server_error(errormsg=rset) + res = [] for row in rset['rows']: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/nodes.sql index ed96b4424..1e84585a2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/nodes.sql @@ -11,4 +11,7 @@ LEFT JOIN pg_depend dep ON (dep.classid = cls.tableoid AND LEFT OUTER JOIN pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid) WHERE indrelid = {{tid}}::oid -AND contype='{{constraint_type}}' \ No newline at end of file +AND contype='{{constraint_type}}' +{% if cid %} +AND cls.oid = {{cid}}::oid +{% endif %} \ No newline at end of file