Add an option to hide/show empty object collection nodes. #5048

This commit is contained in:
Aditya Toshniwal authored and GitHub committed 2023-05-22 14:55:01 +05:30
1 parent c9013a39b8
commit cedfd12f6a
85 files changed
+630 -128

No files matched your search

@@ -60,7 +60,9 @@ class CastModule(CollectionNodeModule):
:param sid: server id
:param did: database id
"""
yield self.generate_browser_collection_node(did)
if self.has_nodes(sid, did,
base_template_path=CastView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(did)
@property
def node_inode(self):
@@ -148,6 +150,7 @@ class CastView(PGChildNodeView, SchemaDiffObjectCompare):
"""
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = 'casts/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -208,7 +211,8 @@ class CastView(PGChildNodeView, SchemaDiffObjectCompare):
).connection_manager(kwargs['sid'])
self.conn = self.manager.connection(did=kwargs['did'])
# Set template path for the SQL scripts
self.template_path = 'casts/sql/#{0}#'.format(self.manager.version)
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
self.datistemplate = False
if (
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_cast ca
WHERE 1=1
{# Check for Show system object #}
{% if (not showsysobj) and datlastsysoid %}
AND ca.oid > {{datlastsysoid}}::OID
{% endif %}
@@ -65,7 +65,10 @@ class EventTriggerModule(CollectionNodeModule):
"""
Generate the event_trigger node
"""
yield self.generate_browser_collection_node(sid)
if self.has_nodes(
sid, did,
base_template_path=EventTriggerView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(sid)
@property
def node_inode(self):
@@ -149,6 +152,7 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_icon = "icon-%s" % blueprint.node_type
BASE_TEMPLATE_PATH = 'event_triggers/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -194,7 +198,7 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
PG_DEFAULT_DRIVER
).connection_manager(kwargs['sid'])
self.conn = self.manager.connection(did=kwargs['did'])
self.template_path = 'event_triggers/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
self.datistemplate = False
@@ -0,0 +1,2 @@
SELECT COUNT(*)
FROM pg_catalog.pg_event_trigger e
@@ -48,7 +48,9 @@ class ExtensionModule(CollectionNodeModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(did)
if self.has_nodes(sid, did,
base_template_path=ExtensionView.EXT_TEMPLATE_PATH):
yield self.generate_browser_collection_node(did)
@property
def node_inode(self):
@@ -0,0 +1,3 @@
SELECT COUNT(*)
FROM pg_catalog.pg_extension x
WHERE 1=1
@@ -75,7 +75,10 @@ class ForeignDataWrapperModule(CollectionNodeModule):
sid: Server ID
did: Database Id
"""
yield self.generate_browser_collection_node(did)
if self.has_nodes(
sid, did,
base_template_path=ForeignDataWrapperView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(did)
@property
def script_load(self):
@@ -179,6 +182,7 @@ class ForeignDataWrapperView(PGChildNodeView, SchemaDiffObjectCompare):
"""
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = 'foreign_data_wrappers/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -235,7 +239,7 @@ class ForeignDataWrapperView(PGChildNodeView, SchemaDiffObjectCompare):
kwargs['did']]['datistemplate']
# Set the template path for the SQL scripts
self.template_path = 'foreign_data_wrappers/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version
)
@@ -0,0 +1,2 @@
SELECT COUNT(*)
FROM pg_catalog.pg_foreign_data_wrapper fdw
@@ -74,7 +74,10 @@ class LanguageModule(CollectionNodeModule):
sid: Server ID
did: Database Id
"""
yield self.generate_browser_collection_node(did)
if self.has_nodes(
sid, did,
base_template_path=LanguageView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(did)
@property
def node_inode(self):
@@ -175,6 +178,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
_NOT_FOUND_LANG_INFORMATION = \
gettext("Could not find the language information.")
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = "languages/sql/#{0}#"
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -241,7 +245,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
# Set the template path for the SQL scripts
self.template_path = (
"languages/sql/#{0}#".format(self.manager.version)
self.BASE_TEMPLATE_PATH.format(self.manager.version)
)
return f(*args, **kwargs)
@@ -73,7 +73,10 @@ class PublicationModule(CollectionNodeModule):
sid: Server ID
did: Database Id
"""
yield self.generate_browser_collection_node(did)
if self.has_nodes(
sid, did,
base_template_path=PublicationView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(did)
@property
def node_inode(self):
@@ -167,6 +170,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
_NOT_FOUND_PUB_INFORMATION = \
gettext("Could not find the publication information.")
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = "publications/sql/#{0}#"
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -223,7 +227,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
self.conn = self.manager.connection(did=kwargs['did'])
# Set the template path for the SQL scripts
self.template_path = (
"publications/sql/#{0}#".format(self.manager.version)
self.BASE_TEMPLATE_PATH.format(self.manager.version)
)
return f(*args, **kwargs)
@@ -0,0 +1,2 @@
SELECT COUNT(*)
FROM pg_catalog.pg_publication c
@@ -67,7 +67,9 @@ class AggregateModule(SchemaChildModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=AggregateView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -118,6 +120,7 @@ class AggregateView(PGChildNodeView):
node_type = blueprint.node_type
node_label = "Aggregate"
BASE_TEMPLATE_PATH = 'aggregates/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -165,10 +168,8 @@ class AggregateView(PGChildNodeView):
kwargs['did']]['datistemplate']
# Set the template path for the SQL scripts
self.template_path = compile_template_path(
'aggregates/sql/',
self.manager.version
)
self.template_path = \
self.BASE_TEMPLATE_PATH.format(self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,4 @@
SELECT COUNT(*)
FROM pg_catalog.pg_aggregate ag
LEFT OUTER JOIN pg_catalog.pg_proc pr ON pr.oid = ag.aggfnoid
WHERE pronamespace = {{scid}}::oid;
@@ -70,7 +70,9 @@ class CollationModule(SchemaChildModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=CollationView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -148,6 +150,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "Collation"
BASE_TEMPLATE_PATH = 'collations/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -202,10 +205,8 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
kwargs['did']]['datistemplate']
# Set the template path for the SQL scripts
self.template_path = compile_template_path(
'collations/sql/',
self.manager.version
)
self.template_path = \
self.BASE_TEMPLATE_PATH.format(self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,5 @@
SELECT COUNT(*)
FROM pg_catalog.pg_collation c
{% if scid %}
WHERE c.collnamespace = {{scid}}::oid
{% endif %}
@@ -61,7 +61,9 @@ class DomainModule(SchemaChildModule):
"""
Generate the domain collection node.
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=DomainView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -151,6 +153,7 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "Domain"
BASE_TEMPLATE_PATH = 'domains/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -301,10 +304,8 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
kwargs['did']]['datistemplate']
# we will set template path for sql scripts
self.template_path = compile_template_path(
'domains/sql/',
self.manager.version
)
self.template_path = \
self.BASE_TEMPLATE_PATH.format(self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,9 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_type d
JOIN
pg_catalog.pg_type b ON b.oid = d.typbasetype
JOIN
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
WHERE
d.typnamespace = {{scid}}::oid
@@ -68,7 +68,10 @@ class ForeignTableModule(SchemaChildModule):
"""
Generate the Foreign Table collection node.
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(
sid, did, scid,
base_template_path=ForeignTableView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def node_inode(self):
@@ -178,6 +181,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
node_type = blueprint.node_type
node_label = "Foreign Table"
BASE_TEMPLATE_PATH = 'foreign_tables/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -390,10 +394,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
# Set template path for sql scripts depending
# on the server version.
self.template_path = compile_template_path(
'foreign_tables/sql/',
self.manager.version
)
self.template_path = \
self.BASE_TEMPLATE_PATH.format(self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_class c
JOIN
pg_catalog.pg_foreign_table ft ON c.oid=ft.ftrelid
WHERE
c.relnamespace = {{scid}}::oid
@@ -68,7 +68,10 @@ class FtsConfigurationModule(SchemaChildModule):
:param did: database id
:param scid: schema id
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(
sid, did, scid,
base_template_path=FtsConfigurationView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def node_inode(self):
@@ -169,6 +172,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
"""
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = 'fts_configurations/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -236,7 +240,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
kwargs['did']]['datistemplate']
# Set the template path for the SQL scripts
self.template_path = 'fts_configurations/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_ts_config cfg
WHERE
{% if scid %}
cfg.cfgnamespace = {{scid}}::OID
{% endif %}
@@ -66,7 +66,10 @@ class FtsDictionaryModule(SchemaChildModule):
:param did: database id
:param scid: schema id
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(
sid, did, scid,
base_template_path=FtsDictionaryView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def node_inode(self):
@@ -161,6 +164,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
"""
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = 'fts_dictionaries/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -225,7 +229,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
kwargs['did']]['datistemplate']
# Set the template path for the SQL scripts
self.template_path = 'fts_dictionaries/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_ts_dict dict
WHERE
{% if scid %}
dict.dictnamespace = {{scid}}::OID
{% endif %}
@@ -59,7 +59,10 @@ class FtsParserModule(SchemaChildModule):
:param did: database id
:param scid: schema id
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=FtsParserView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def node_inode(self):
@@ -163,6 +166,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
"""
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = 'fts_parsers/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -238,7 +242,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
self.datistemplate = self.manager.db_info[
kwargs['did']]['datistemplate']
# Set the template path for the SQL scripts
self.template_path = 'fts_parsers/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_ts_parser prs
WHERE
{% if scid %}
prs.prsnamespace = {{scid}}::OID
{% endif %}
@@ -65,7 +65,10 @@ class FtsTemplateModule(SchemaChildModule):
:param did: database id
:param scid: schema id
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(
sid, did, scid,
base_template_path=FtsTemplateView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def node_inode(self):
@@ -157,6 +160,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "FTS Template"
BASE_TEMPLATE_PATH = 'fts_templates/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -217,7 +221,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
):
self.datistemplate = self.manager.db_info[
kwargs['did']]['datistemplate']
self.template_path = 'fts_templates/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_ts_template tmpl
WHERE
{% if scid %}
tmpl.tmplnamespace = {{scid}}::OID
{% endif %}
@@ -81,7 +81,9 @@ class FunctionModule(SchemaChildModule):
"""
Generate Functions collection node.
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=FunctionView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def node_inode(self):
@@ -185,7 +187,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
"""
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = 'functions/{0}/sql/#{1}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
{'type': 'int', 'id': 'sid'},
@@ -351,21 +353,9 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
self.qtIdent = driver.qtIdent
self.qtLiteral = driver.qtLiteral
template_initial = None
if self.node_type == 'function':
template_initial = 'functions'
elif self.node_type == 'procedure':
template_initial = 'procedures'
elif self.node_type == 'trigger_function':
template_initial = 'trigger_functions'
# Set the template path for the SQL scripts
self.sql_template_path = "/".join([
template_initial,
self.manager.server_type,
'sql',
'#{0}#'
]).format(self.manager.version)
self.sql_template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.server_type, self.manager.version)
return f(*args, **kwargs)
@@ -2074,7 +2064,9 @@ class ProcedureModule(SchemaChildModule):
"""
Generate Procedures collection node.
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=ProcedureView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def node_inode(self):
@@ -2099,6 +2091,7 @@ procedure_blueprint = ProcedureModule(__name__)
class ProcedureView(FunctionView):
node_type = procedure_blueprint.node_type
BASE_TEMPLATE_PATH = 'procedures/{0}/sql/#{1}#'
def __init__(self, *args, **kwargs):
"""
@@ -2172,7 +2165,10 @@ class TriggerFunctionModule(SchemaChildModule):
"""
Generate Trigger function collection node.
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(
sid, did, scid,
base_template_path=TriggerFunctionView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def node_inode(self):
@@ -2197,6 +2193,7 @@ trigger_function_blueprint = TriggerFunctionModule(__name__)
class TriggerFunctionView(FunctionView):
node_type = trigger_function_blueprint.node_type
BASE_TEMPLATE_PATH = 'trigger_functions/{0}/sql/#{1}#'
def __init__(self, *args, **kwargs):
"""
@@ -0,0 +1,9 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
WHERE
pr.prokind IN ('f', 'w')
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,13 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
proisagg = FALSE
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid
@@ -0,0 +1,9 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
WHERE
pr.prokind IN ('f', 'w')
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid
@@ -0,0 +1,13 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
proisagg = FALSE
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid
@@ -0,0 +1,13 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
pr.prokind = 'p'
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,13 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
pr.prokind = 'p'
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,13 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
pr.prokind = 'p'::char
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,13 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
pr.prokind = 'p'::char
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,13 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
proisagg = FALSE
AND typname NOT IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,14 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
pr.prokind IN ('f', 'w')
AND typname IN ('trigger', 'event_trigger')
AND lanname NOT IN ('edbspl', 'sql', 'internal')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,14 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
proisagg = FALSE
AND typname IN ('trigger', 'event_trigger')
AND lanname NOT IN ('edbspl', 'sql', 'internal')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,13 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
pr.prokind IN ('f', 'w')
AND typname IN ('trigger', 'event_trigger')
AND pronamespace = {{scid}}::oid;
@@ -0,0 +1,14 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
WHERE
proisagg = FALSE
AND typname IN ('trigger', 'event_trigger')
AND lanname NOT IN ('sql', 'internal')
AND pronamespace = {{scid}}::oid;
@@ -67,7 +67,9 @@ class OperatorModule(SchemaChildModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=OperatorView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -117,6 +119,7 @@ class OperatorView(PGChildNodeView):
node_type = blueprint.node_type
node_label = "Operator"
BASE_TEMPLATE_PATH = 'operators/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -164,8 +167,10 @@ class OperatorView(PGChildNodeView):
kwargs['did']]['datistemplate']
# Set the template path for the SQL scripts
self.template_path = \
self.BASE_TEMPLATE_PATH.format(self.manager.version)
self.template_path = compile_template_path(
'operators/sql/',
self.BASE_TEMPLATE_PATH,
self.manager.version
)
@@ -0,0 +1,6 @@
SELECT COUNT(*)
FROM pg_catalog.pg_operator op
JOIN pg_catalog.pg_type et on et.oid=op.oprresult
{% if scid %}
WHERE op.oprnamespace = {{scid}}::oid
{% endif %}
@@ -66,7 +66,9 @@ class PackageModule(SchemaChildModule):
"""
Generate the package node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=PackageView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -99,6 +101,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "Package"
node_icon = "icon-%s" % node_type
BASE_TEMPLATE_PATH = 'packages/ppas/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -153,7 +156,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
"Connection to the server has been lost."
)
)
self.template_path = 'packages/ppas/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
sql = render_template(
@@ -0,0 +1,6 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_namespace nsp
WHERE nspparent = {{scid}}::oid
AND nspobjecttype = 0
AND nspcompoundtrigger = false
@@ -0,0 +1,5 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_namespace nsp
WHERE nspparent = {{scid}}::oid
AND nspobjecttype = 0;
@@ -64,7 +64,9 @@ class SequenceModule(SchemaChildModule):
"""
Generate the sequence node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=SequenceView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -91,6 +93,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "Sequence"
node_icon = "icon-%s" % node_type
BASE_TEMPLATE_PATH = 'sequences/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -148,7 +151,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
self.datistemplate = self.manager.db_info[
kwargs['did']]['datistemplate']
self.template_path = 'sequences/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version
)
self.acl = ['r', 'w', 'U']
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_class cl
WHERE
relkind = 'S'
{% if scid %}
AND relnamespace = {{scid|qtLiteral(conn)}}::oid
{% endif %}
@@ -70,7 +70,9 @@ class SynonymModule(SchemaChildModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=SynonymView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -148,6 +150,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "Synonym"
BASE_TEMPLATE_PATH = 'synonyms/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -216,7 +219,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
kwargs['did']]['datistemplate']
# we will set template path for sql scripts
self.template_path = 'synonyms/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,4 @@
SELECT COUNT(*)
FROM pg_catalog.pg_synonym s
JOIN pg_catalog.pg_namespace ns ON s.synnamespace = ns.oid
AND s.synnamespace = {{scid}}::oid
@@ -72,7 +72,9 @@ class TableModule(SchemaChildModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=BaseTableView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -72,9 +72,13 @@ class ColumnsModule(CollectionNodeModule):
Generate the collection node
"""
assert ('tid' in kwargs or 'vid' in kwargs)
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
)
if self.has_nodes(sid, did, scid=scid,
tid=kwargs.get('tid', None),
vid=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']
)
@property
def script_load(self):
@@ -159,6 +163,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
node_type = blueprint.node_type
node_label = "Column"
BASE_TEMPLATE_PATH = 'columns/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -207,7 +212,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
self.qtTypeIdent = driver.qtTypeIdent
# Set the template path for the SQL scripts
self.template_path = 'columns/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
# Allowed ACL for column 'Select/Update/Insert/References'
@@ -105,9 +105,13 @@ class CompoundTriggerModule(CollectionNodeModule):
Generate the collection node
"""
assert ('tid' in kwargs or 'vid' in kwargs)
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
)
if self.has_nodes(
sid, did, scid=scid, tid=kwargs.get('tid', None),
vid=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']
)
@property
def script_load(self):
@@ -216,6 +220,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "Compound Trigger"
BASE_TEMPLATE_PATH = 'compound_triggers/sql/{0}/#{1}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -278,7 +283,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
)
# we will set template path for sql scripts
self.template_path = 'compound_triggers/sql/{0}/#{1}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.server_type, self.manager.version)
# Store server type
self.server_type = self.manager.server_type
@@ -103,9 +103,13 @@ class IndexesModule(CollectionNodeModule):
Generate the collection node
"""
assert ('tid' in kwargs or 'vid' in kwargs)
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
)
if self.has_nodes(sid, did, scid=scid,
tid=kwargs.get('tid', None),
vid=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']
)
@property
def script_load(self):
@@ -194,6 +198,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "Index"
BASE_TEMPLATE_PATH = 'indexes/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -252,8 +257,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
)
# we will set template path for sql scripts
self.template_path = compile_template_path(
'indexes/sql/',
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version
)
@@ -60,14 +60,18 @@ class RowSecurityModule(CollectionNodeModule):
self.min_ver = 90500
self.max_ver = None
def get_nodes(self, **kwargs):
def get_nodes(self, gid, sid, did, scid, **kwargs):
"""
Generate the collection node
"""
assert ('tid' in kwargs or 'vid' in kwargs)
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
)
if self.has_nodes(
sid, did, scid=scid, tid=kwargs.get('tid', None),
vid=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']
)
@property
def node_inode(self):
@@ -148,6 +152,7 @@ class RowSecurityView(PGChildNodeView):
node_type = blueprint.node_type
node_label = "RLS Policy"
BASE_TEMPLATE_PATH = 'row_security_policies/sql/#{0}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -205,7 +210,7 @@ class RowSecurityView(PGChildNodeView):
'tables/sql',
self.manager.version
)
self.template_path = 'row_security_policies/sql/#{0}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version)
return f(*args, **kwargs)
@@ -80,9 +80,13 @@ class RuleModule(CollectionNodeModule):
Generate the collection node
"""
assert ('tid' in kwargs or 'vid' in kwargs)
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
)
if self.has_nodes(sid, did, scid=scid,
tid=kwargs.get('tid', None),
vid=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']
)
@property
def node_inode(self):
@@ -150,6 +154,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
"""
node_type = blueprint.node_type
node_label = "Rule"
BASE_TEMPLATE_PATH = 'rules/sql'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -197,7 +202,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
self.manager = get_driver(
PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
self.conn = self.manager.connection(did=kwargs['did'])
self.template_path = 'rules/sql'
self.template_path = self.BASE_TEMPLATE_PATH
self.table_template_path = compile_template_path(
'tables/sql',
self.manager.version
@@ -0,0 +1,9 @@
SELECT COUNT(*)
FROM pg_catalog.pg_attribute att
WHERE
att.attrelid = {{ tid|qtLiteral(conn) }}::oid
{### To show system objects ###}
{% if not showsysobj %}
AND att.attnum > 0
{% endif %}
AND att.attisdropped IS FALSE
@@ -0,0 +1,5 @@
SELECT COUNT(*)
FROM pg_catalog.pg_trigger t
WHERE NOT tgisinternal
AND tgrelid = {{tid}}::OID
AND tgpackageoid != 0
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_index idx
JOIN pg_catalog.pg_class cls ON cls.oid=indexrelid
LEFT JOIN pg_catalog.pg_depend dep ON (dep.classid = cls.tableoid AND dep.objid = cls.oid AND dep.refobjsubid = '0' AND dep.refclassid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='pg_constraint') AND dep.deptype='i')
LEFT OUTER JOIN pg_catalog.pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid)
WHERE indrelid = {{tid}}::OID
AND conname is NULL
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_policy pl
WHERE
{% if tid %}
pl.polrelid = {{ tid }}
{% endif %}
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM
pg_catalog.pg_rewrite rw
WHERE
{% if tid %}
rw.ev_class = {{ tid }}
{% endif %}
@@ -0,0 +1,4 @@
SELECT COUNT(*)
FROM pg_catalog.pg_class rel
WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid
AND NOT rel.relispartition;
@@ -0,0 +1,4 @@
SELECT COUNT(*)
FROM pg_catalog.pg_trigger t
WHERE NOT tgisinternal
AND tgrelid = {{tid}}::OID
@@ -0,0 +1,5 @@
SELECT COUNT(*)
FROM pg_catalog.pg_trigger t
WHERE NOT tgisinternal
AND tgrelid = {{tid}}::OID
AND tgpackageoid = 0
@@ -0,0 +1,4 @@
SELECT COUNT(*)
FROM pg_catalog.pg_trigger t
WHERE NOT tgisinternal
AND tgrelid = {{tid}}::OID
@@ -101,9 +101,13 @@ class TriggerModule(CollectionNodeModule):
Generate the collection node
"""
assert ('tid' in kwargs or 'vid' in kwargs)
yield self.generate_browser_collection_node(
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
)
if self.has_nodes(sid, did, scid=scid,
tid=kwargs.get('tid', None),
vid=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']
)
@property
def script_load(self):
@@ -213,6 +217,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type
node_label = "Trigger"
BASE_TEMPLATE_PATH = 'triggers/sql/{0}/#{1}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -266,7 +271,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
'tables/sql',
self.manager.version
)
self.template_path = 'triggers/sql/{0}/#{1}#'.format(
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.server_type, self.manager.version)
self.trigger_function_template_path = \
@@ -90,6 +90,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
node_label = "Table"
pattern = '\n{2,}'
double_newline = '\n\n'
BASE_TEMPLATE_PATH = 'tables/sql/#{0}#'
@staticmethod
def check_precondition(f):
@@ -71,7 +71,9 @@ class TypeModule(SchemaChildModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(sid, did, scid=scid,
base_template_path=TypeView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -179,6 +181,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
node_type = blueprint.node_type
icon_str = "icon-%s"
BASE_TEMPLATE_PATH = 'types/{0}/sql/#{1}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -238,12 +241,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
# Declare allows acl on type
self.acl = ['U']
self.template_path = "/".join([
'types',
self.manager.server_type,
'sql',
'#{0}#'
]).format(self.manager.version)
self.template_path = self.BASE_TEMPLATE_PATH.format(
self.manager.server_type, self.manager.version)
return f(*args, **kwargs)
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_type t
LEFT OUTER JOIN pg_catalog.pg_class ct ON ct.oid=t.typrelid AND ct.relkind <> 'c'
WHERE t.typtype != 'd' AND t.typname NOT LIKE E'\\_%' AND t.typnamespace = {{scid}}::oid
{% if not showsysobj %}
AND ct.oid is NULL
{% endif %}
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_type t
LEFT OUTER JOIN pg_catalog.pg_class ct ON ct.oid=t.typrelid AND ct.relkind <> 'c'
WHERE t.typtype != 'd' AND t.typname NOT LIKE E'\\_%' AND t.typnamespace = {{scid}}::oid
{% if not showsysobj %}
AND ct.oid is NULL
{% endif %}
@@ -91,7 +91,10 @@ class ViewModule(SchemaChildModule):
"""
Generate the collection node
"""
yield self.generate_browser_collection_node(scid)
if self.has_nodes(
sid, did, scid, base_template_path=ViewNode.BASE_TEMPLATE_PATH +
'/' + ViewNode._SQL_PREFIX):
yield self.generate_browser_collection_node(scid)
@property
def script_load(self):
@@ -216,6 +219,15 @@ class MViewModule(ViewModule):
self.min_ver = 90300
self.max_ver = None
def get_nodes(self, gid, sid, did, scid):
"""
Generate the collection node
"""
if self.has_nodes(
sid, did, scid, base_template_path=MViewNode.BASE_TEMPLATE_PATH +
'/' + MViewNode._SQL_PREFIX):
yield self.generate_browser_collection_node(scid)
view_blueprint = ViewModule(__name__)
mview_blueprint = MViewModule(__name__)
@@ -242,12 +254,8 @@ def check_precondition(f):
kwargs['sid']
)
self.conn = self.manager.connection(did=kwargs['did'])
# Set template path for 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)
self.column_template_path = 'columns/sql/#{0}#'.format(
self.manager.version)
@@ -327,6 +335,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
_SQL_PREFIX = 'sql/'
_ALLOWED_PRIVS_JSON = 'sql/allowed_privs.json'
PROPERTIES_PATH = 'sql/{0}/#{1}#/properties.sql'
BASE_TEMPLATE_PATH = 'views/{0}/#{1}#'
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -377,23 +386,8 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
self.manager = None
self.conn = None
self.template_path = None
self.template_initial = 'views'
self.allowed_acls = []
@staticmethod
def ppas_template_path(ver):
"""
Returns the template path for PPAS servers.
"""
return 'ppas/#{0}#'.format(ver)
@staticmethod
def pg_template_path(ver):
"""
Returns the template path for PostgreSQL servers.
"""
return 'pg/#{0}#'.format(ver)
@check_precondition
def list(self, gid, sid, did, scid):
"""
@@ -1797,6 +1791,7 @@ class MViewNode(ViewNode, VacuumSettings):
node_type = mview_blueprint.node_type
operations = mview_operations
TOAST_STR = 'toast.'
BASE_TEMPLATE_PATH = 'mviews/{0}/#{1}#'
def __init__(self, *args, **kwargs):
"""
@@ -1805,7 +1800,6 @@ class MViewNode(ViewNode, VacuumSettings):
super().__init__(*args, **kwargs)
self.template_initial = 'mviews'
self.allowed_acls = []
@staticmethod
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_class c
WHERE
c.relkind = 'm'
{% if scid %}
AND c.relnamespace = {{scid}}::oid
{% endif %}
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_class c
WHERE
c.relkind = 'm'
{% if scid %}
AND c.relnamespace = {{scid}}::oid
{% endif %}
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_class c
WHERE
c.relkind = 'v'
{% if scid %}
AND c.relnamespace = {{scid}}::oid
{% endif %}
@@ -0,0 +1,7 @@
SELECT COUNT(*)
FROM pg_catalog.pg_class c
WHERE
c.relkind = 'v'
{% if scid %}
AND c.relnamespace = {{scid}}::oid
{% endif %}
@@ -74,7 +74,10 @@ class SubscriptionModule(CollectionNodeModule):
sid: Server ID
did: Database Id
"""
yield self.generate_browser_collection_node(did)
if self.has_nodes(
sid, did,
base_template_path=SubscriptionView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(did)
@property
def node_inode(self):
@@ -176,6 +179,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
_NOT_FOUND_PUB_INFORMATION = \
gettext("Could not find the subscription information.")
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = "subscriptions/sql/#{0}#"
parent_ids = [
{'type': 'int', 'id': 'gid'},
@@ -232,7 +236,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
self.conn = self.manager.connection(did=kwargs['did'])
# Set the template path for the SQL scripts
self.template_path = (
"subscriptions/sql/#{0}#".format(self.manager.version)
self.BASE_TEMPLATE_PATH.format(self.manager.version)
)
return f(*args, **kwargs)
@@ -0,0 +1,3 @@
SELECT COUNT(*)
FROM pg_catalog.pg_subscription sub
WHERE sub.subdbid = {{ did }}
@@ -79,7 +79,10 @@ class ResourceGroupModule(CollectionNodeModule):
gid: Server Group ID
sid: Server ID
"""
yield self.generate_browser_collection_node(sid)
if self.has_nodes(
sid, None,
base_template_path=ResourceGroupView.BASE_TEMPLATE_PATH):
yield self.generate_browser_collection_node(sid)
@property
def node_inode(self):
@@ -165,6 +168,7 @@ class ResourceGroupView(NodeView):
"""
node_type = blueprint.node_type
BASE_TEMPLATE_PATH = 'resource_groups/sql/#{0}#'
_PROPERTIES_SQL = 'properties.sql'
_CREATE_SQL = 'create.sql'
_UPDATE_SQL = 'update.sql'
@@ -236,7 +240,7 @@ class ResourceGroupView(NodeView):
"Connection to the server has been lost."
)
)
self.sql_path = 'resource_groups/sql/#{0}#'.format(
self.sql_path = self.BASE_TEMPLATE_PATH.format(
self.manager.version
)
return f(*args, **kwargs)
@@ -0,0 +1,2 @@
SELECT COUNT(*)
FROM edb_resource_group