Fix display of exclusion contraint dependencies. Partially fixes #1892 - requires icon display fix.

This commit is contained in:
Murtuza Zabuawala 2016-11-01 11:35:09 +02:00 committed by Dave Page
parent ca57323ad1
commit a3622a380a
6 changed files with 122 additions and 2 deletions

View File

@ -159,6 +159,13 @@ class ExclusionConstraintView(PGChildNodeView):
* get_operator(): * get_operator():
- Returns operators for selected column. - Returns operators for selected column.
* dependency():
- This function will generate dependency list show it in dependency
pane for the selected Exclusion.
* dependent():
- This function will generate dependent list to show it in dependent
pane for the selected Exclusion.
""" """
node_type = 'exclusion_constraint' node_type = 'exclusion_constraint'
@ -184,6 +191,8 @@ class ExclusionConstraintView(PGChildNodeView):
'sql': [{'get': 'sql'}], 'sql': [{'get': 'sql'}],
'msql': [{'get': 'msql'}, {'get': 'msql'}], 'msql': [{'get': 'msql'}, {'get': 'msql'}],
'stats': [{'get': 'statistics'}], 'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'module.js': [{}, {}, {'get': 'module_js'}] 'module.js': [{}, {}, {'get': 'module_js'}]
}) })
@ -400,7 +409,8 @@ class ExclusionConstraintView(PGChildNodeView):
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), 'nodes.sql']),
cid=exid) tid=tid,
exid=exid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
@ -941,6 +951,53 @@ class ExclusionConstraintView(PGChildNodeView):
status=200 status=200
) )
@check_precondition
def dependents(self, gid, sid, did, scid, tid, exid):
"""
This function get the dependents and return ajax response
for the constraint node.
Args:
gid: Server Group ID
sid: Server ID
did: Database ID
scid: Schema ID
tid: Table ID
exid: Exclusion constraint ID
"""
dependents_result = self.get_dependents(
self.conn, exid
)
return ajax_response(
response=dependents_result,
status=200
)
@check_precondition
def dependencies(self, gid, sid, did, scid, tid, exid):
"""
This function get the dependencies and return ajax response
for the constraint node.
Args:
gid: Server Group ID
sid: Server ID
did: Database ID
scid: Schema ID
tid: Table ID
exid: Exclusion constraint ID
"""
dependencies_result = self.get_dependencies(
self.conn, exid
)
return ajax_response(
response=dependencies_result,
status=200
)
constraint = ConstraintRegistry( constraint = ConstraintRegistry(
'exclusion_constraint', ExclusionConstraintModule, ExclusionConstraintView 'exclusion_constraint', ExclusionConstraintModule, ExclusionConstraintView

View File

@ -175,6 +175,13 @@ class IndexConstraintView(PGChildNodeView):
* get_indices(): * get_indices():
- This function returns indices for current table. - This function returns indices for current table.
* dependency():
- This function will generate dependency list show it in dependency
pane for the selected Index constraint.
* dependent():
- This function will generate dependent list to show it in dependent
pane for the selected Index constraint.
""" """
node_type = 'index_constraint' node_type = 'index_constraint'
@ -971,6 +978,53 @@ class IndexConstraintView(PGChildNodeView):
status=200 status=200
) )
@check_precondition
def dependents(self, gid, sid, did, scid, tid, cid):
"""
This function get the dependents and return ajax response
for the constraint node.
Args:
gid: Server Group ID
sid: Server ID
did: Database ID
scid: Schema ID
tid: Table ID
cid: Index constraint ID
"""
dependents_result = self.get_dependents(
self.conn, cid
)
return ajax_response(
response=dependents_result,
status=200
)
@check_precondition
def dependencies(self, gid, sid, did, scid, tid, cid):
"""
This function get the dependencies and return ajax response
for the constraint node.
Args:
gid: Server Group ID
sid: Server ID
did: Database ID
scid: Schema ID
tid: Table ID
cid: Index constraint ID
"""
dependencies_result = self.get_dependencies(
self.conn, cid
)
return ajax_response(
response=dependencies_result,
status=200
)
class PrimaryKeyConstraintView(IndexConstraintView): class PrimaryKeyConstraintView(IndexConstraintView):
node_type = 'primary_key' node_type = 'primary_key'

View File

@ -17,7 +17,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
dialogHelp: '{{ url_for('help.static', filename='unique_constraint_dialog.html') }}', dialogHelp: '{{ url_for('help.static', filename='unique_constraint_dialog.html') }}',
{% endif %} {% endif %}
hasSQL: true, hasSQL: true,
hasDepends: false, hasDepends: true,
hasStatistics: true, hasStatistics: true,
parent_type: 'table', parent_type: 'table',
canDrop: true, canDrop: true,

View File

@ -4,4 +4,7 @@ SELECT conindid as oid,
FROM pg_constraint ct FROM pg_constraint ct
WHERE contype='x' AND WHERE contype='x' AND
conrelid = {{tid}}::oid conrelid = {{tid}}::oid
{% if exid %}
AND conindid = {{exid}}::oid
{% endif %}
ORDER BY conname ORDER BY conname

View File

@ -4,4 +4,7 @@ SELECT conindid as oid,
FROM pg_constraint ct FROM pg_constraint ct
WHERE contype='x' AND WHERE contype='x' AND
conrelid = {{tid}}::oid conrelid = {{tid}}::oid
{% if exid %}
AND conindid = {{exid}}::oid
{% endif %}
ORDER BY conname ORDER BY conname

View File

@ -4,4 +4,7 @@ SELECT conindid as oid,
FROM pg_constraint ct FROM pg_constraint ct
WHERE contype='x' AND WHERE contype='x' AND
conrelid = {{tid}}::oid conrelid = {{tid}}::oid
{% if exid %}
AND conindid = {{exid}}::oid
{% endif %}
ORDER BY conname ORDER BY conname