Ensure the treeview shows all sequences except those used to implement IDENTITY columns (which can be edited as part of the column). Show all if Show System Objects is enabled. Fixes #4154

This commit is contained in:
Dave Page
2019-04-26 12:36:56 +01:00
parent e536408ce2
commit e53c2b1a5d
2 changed files with 33 additions and 11 deletions

View File

@@ -26,6 +26,7 @@ Bug fixes
| `Bug #4121 <https://redmine.postgresql.org/issues/4121>`_ - Fixed alignment issue of columns in definition section of Index node.
| `Bug #4134 <https://redmine.postgresql.org/issues/4134>`_ - Fixed 'Location cannot be empty' error when open Tablespace properties.
| `Bug #4138 <https://redmine.postgresql.org/issues/4138>`_ - Fix an issue where the dropdown becomes misaligned/displaced.
| `Bug #4154 <https://redmine.postgresql.org/issues/4154>`_ - Ensure the treeview shows all sequences except those used to implement IDENTITY columns (which can be edited as part of the column). Show all if Show System Objects is enabled.
| `Bug #4160 <https://redmine.postgresql.org/issues/4160>`_ - Fixed 'Increment value cannot be empty' error for existing tables.
| `Bug #4161 <https://redmine.postgresql.org/issues/4161>`_ - Ensure that parameters of procedures for EPAS server 10 and below should be set/reset properly.
| `Bug #4163 <https://redmine.postgresql.org/issues/4163>`_ - Prevent duplicate columns being included in reverse engineered SQL for tables.

View File

@@ -183,8 +183,10 @@ class SequenceView(PGChildNodeView):
if not status:
return internal_server_error(errormsg=res)
sequence_nodes = self._get_sequence_nodes(res['rows'])
return ajax_response(
response=res['rows'],
response=sequence_nodes,
status=200
)
@@ -227,16 +229,8 @@ class SequenceView(PGChildNodeView):
status=200
)
for row in rset['rows']:
if not self.blueprint.show_system_objects:
system_seq = self._get_dependency(row['oid'],
show_system_objects=True)
seq = filter(lambda dep: dep['type'] == 'column', system_seq)
if type(seq) is not list:
seq = list(seq)
if len(seq) > 0:
continue
sequence_nodes = self._get_sequence_nodes(rset['rows'])
for row in sequence_nodes:
res.append(
self.blueprint.generate_browser_node(
row['oid'],
@@ -250,6 +244,33 @@ class SequenceView(PGChildNodeView):
status=200
)
def _get_sequence_nodes(self, nodes):
"""
This function is used to iterate through all the sequences node and
hiding sequences created as part of an IDENTITY column.
:param nodes:
:return:
"""
# If show_system_objects is true then no need to hide any sequences.
if self.blueprint.show_system_objects:
return nodes
seq_nodes = []
for row in nodes:
system_seq = self._get_dependency(row['oid'],
show_system_objects=True)
seq = filter(lambda dep: dep['type'] == 'column' and
dep['field'] == 'internal', system_seq)
if type(seq) is not list:
seq = list(seq)
if len(seq) > 0:
continue
# Append the node into the newly created list
seq_nodes.append(row)
return seq_nodes
@check_precondition(action='properties')
def properties(self, gid, sid, did, scid, seid):
"""