Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ def get_children_nodes(self, manager, **kwargs):
sql = render_template("/".join(
[self.trigger_function_template_path, self._NODE_SQL]),
scid=trigger_function_schema_oid,
fnid=rset['rows'][0]['tfuncoid']
fnid=rset['rows'][0]['tfuncoid'],
conn=self.conn
)
status, res = self.conn.execute_2darray(sql)
if not status:
Expand Down
16 changes: 15 additions & 1 deletion web/pgadmin/browser/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,12 @@ def children(self, *args, **kwargs):
"""Build a list of treeview nodes from the child nodes."""
children = self.get_children_nodes(*args, **kwargs)

# get_children_nodes may return a Flask Response (e.g. an error
# response) instead of a list of nodes. In that case return it as-is
# rather than trying to iterate/sort it.
if isinstance(children, flask.Response):
return children

# Return sorted nodes based on label
return make_json_response(
data=sorted(
Expand Down Expand Up @@ -453,10 +459,18 @@ def children(self, **kwargs):
)
)

children = self.get_children_nodes(manager, **kwargs)

# get_children_nodes may return a Flask Response (e.g. an error
# response) instead of a list of nodes. In that case return it as-is
# rather than trying to iterate/sort it.
if isinstance(children, flask.Response):
return children

# Return sorted nodes based on label
return make_json_response(
data=sorted(
self.get_children_nodes(manager, **kwargs),
children,
key=lambda c: c['label']
)
)
Expand Down
Loading