Fix issues related to show/hide empty nodes feature. #5048

pull/6329/head
Aditya Toshniwal 2023-05-26 18:07:51 +05:30 committed by GitHub
parent b337b64eb1
commit 72794f9524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 59 additions and 21 deletions

View File

@ -0,0 +1,4 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_language lan JOIN pg_catalog.pg_proc hp ON hp.oid=lanplcallfoid
WHERE lanispl IS TRUE

View File

@ -85,7 +85,11 @@ class SchemaModule(CollectionNodeModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(did)
if self.has_nodes(
sid, did,
base_template_path=SchemaView.BASE_TEMPLATE_PATH +
'/' + SchemaView._SQL_PREFIX):
yield self.generate_browser_collection_node(did)
@property
def script_load(self):
@ -188,6 +192,12 @@ class CatalogModule(SchemaModule):
"""
super().register(app, options)
def get_nodes(self, gid, sid, did):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(did)
schema_blueprint = SchemaModule(__name__)
catalog_blueprint = CatalogModule(__name__)
@ -224,11 +234,8 @@ def check_precondition(f):
kwargs['did']]['datistemplate']
# Set the template path for the SQL scripts
if self.manager.server_type == 'ppas':
_temp = self.ppas_template_path(self.manager.version)
else:
_temp = self.pg_template_path(self.manager.version)
self.template_path = self.template_initial + '/' + _temp
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.server_type, self.manager.version)
return f(*args, **kwargs)
@ -286,6 +293,7 @@ class SchemaView(PGChildNodeView):
node_type = schema_blueprint.node_type
_SQL_PREFIX = 'sql/'
node_icon = 'icon-%s' % node_type
BASE_TEMPLATE_PATH = 'schemas/{0}/#{1}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@ -322,7 +330,6 @@ class SchemaView(PGChildNodeView):
self.manager = None
self.conn = None
self.template_path = None
self.template_initial = 'schemas'
@staticmethod
def ppas_template_path(ver):
@ -1071,6 +1078,7 @@ class CatalogView(SchemaView):
"""
node_type = catalog_blueprint.node_type
BASE_TEMPLATE_PATH = 'catalog/{0}/#{1}#'
def __init__(self, *args, **kwargs):
"""
@ -1079,8 +1087,6 @@ class CatalogView(SchemaView):
super().__init__(*args, **kwargs)
self.template_initial = 'catalog'
def _formatter(self, data, scid=None):
"""

View File

@ -73,8 +73,7 @@ class ColumnsModule(CollectionNodeModule):
"""
assert ('tid' in kwargs or 'vid' in kwargs)
if self.has_nodes(sid, did, scid=scid,
tid=kwargs.get('tid', None),
vid=kwargs.get('vid', None),
tid=kwargs.get('tid', kwargs.get('vid', None)),
base_template_path=ColumnsView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']

View File

@ -106,8 +106,8 @@ class CompoundTriggerModule(CollectionNodeModule):
"""
assert ('tid' in kwargs or 'vid' in kwargs)
if self.has_nodes(
sid, did, scid=scid, tid=kwargs.get('tid', None),
vid=kwargs.get('vid', None),
sid, did, scid=scid,
tid=kwargs.get('tid', kwargs.get('vid', None)),
base_template_path=CompoundTriggerView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']

View File

@ -104,8 +104,7 @@ class IndexesModule(CollectionNodeModule):
"""
assert ('tid' in kwargs or 'vid' in kwargs)
if self.has_nodes(sid, did, scid=scid,
tid=kwargs.get('tid', None),
vid=kwargs.get('vid', None),
tid=kwargs.get('tid', kwargs.get('vid', None)),
base_template_path=IndexesView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']

View File

@ -66,8 +66,8 @@ class RowSecurityModule(CollectionNodeModule):
"""
assert ('tid' in kwargs or 'vid' in kwargs)
if self.has_nodes(
sid, did, scid=scid, tid=kwargs.get('tid', None),
vid=kwargs.get('vid', None),
sid, did, scid=scid,
tid=kwargs.get('tid', kwargs.get('vid', None)),
base_template_path=RowSecurityView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']

View File

@ -81,8 +81,7 @@ class RuleModule(CollectionNodeModule):
"""
assert ('tid' in kwargs or 'vid' in kwargs)
if self.has_nodes(sid, did, scid=scid,
tid=kwargs.get('tid', None),
vid=kwargs.get('vid', None),
tid=kwargs.get('tid', kwargs.get('vid', None)),
base_template_path=RuleView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']

View File

@ -102,8 +102,7 @@ class TriggerModule(CollectionNodeModule):
"""
assert ('tid' in kwargs or 'vid' in kwargs)
if self.has_nodes(sid, did, scid=scid,
tid=kwargs.get('tid', None),
vid=kwargs.get('vid', None),
tid=kwargs.get('tid', kwargs.get('vid', None)),
base_template_path=TriggerView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']

View File

@ -0,0 +1,11 @@
{% import 'catalog/pg/macros/catalogs.sql' as CATALOGS %}
SELECT COUNT(*)
FROM
pg_catalog.pg_namespace nsp
WHERE
{% if not showsysobj %}
nspname NOT LIKE E'pg\\_%' AND
{% endif %}
NOT (
{{ CATALOGS.LIST('nsp') }}
)

View File

@ -0,0 +1,21 @@
{% import 'catalog/ppas/macros/catalogs.sql' as CATALOGS %}
SELECT COUNT(*)
FROM
pg_catalog.pg_namespace nsp
WHERE
nsp.nspparent = 0 AND
{% if scid %}
nsp.oid={{scid}}::oid AND
{% else %}
{% if not show_sysobj %}
nspname NOT LIKE 'pg!_%' escape '!' AND
{% endif %}
{% endif %}
NOT (
{{ CATALOGS.LIST('nsp') }}
)
{% if schema_restrictions %}
AND
nsp.nspname in ({{schema_restrictions}})
{% endif %}
ORDER BY nspname;