Fix refreshing of Unique constraints. Fixes #1893

pull/3/head
Murtuza Zabuawala 2016-10-28 16:40:27 +01:00 committed by Dave Page
parent 8c48be3b0c
commit 67e5dfa5a7
2 changed files with 11 additions and 1 deletions

View File

@ -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']:

View File

@ -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}}'
AND contype='{{constraint_type}}'
{% if cid %}
AND cls.oid = {{cid}}::oid
{% endif %}