Fix multiple object breadcrumbs bugs. #2078

This commit is contained in:
Aditya Toshniwal
2023-05-03 15:18:17 +05:30
committed by GitHub
parent cba42ef277
commit 4fbfcdfee9
13 changed files with 72 additions and 23 deletions

View File

@@ -1,6 +1,8 @@
SELECT
c.oid, c.relname as name
c.oid, c.relname as name, description
FROM pg_catalog.pg_class c
LEFT OUTER JOIN pg_catalog.pg_description d
ON d.objoid=c.oid AND d.classoid='pg_class'::regclass
{% if scid %}
WHERE relnamespace = {{scid}}::oid
OR (

View File

@@ -1,7 +1,8 @@
SELECT
nsp.oid, nspname AS name
nsp.oid, nspname AS name, des.description
FROM
pg_catalog.pg_namespace nsp
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=nsp.oid AND des.classoid='pg_namespace'::regclass)
WHERE nspparent = {{scid}}::oid
{% if pkgid %}
AND nsp.oid = {{pkgid}}::oid

View File

@@ -243,7 +243,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
scid,
row['name'],
icon=self.node_icon,
description=row['description']
description=row['comment']
))
return make_json_response(

View File

@@ -482,7 +482,8 @@ class ForeignKeyConstraintView(PGChildNodeView):
tid,
row['name'],
icon=icon,
valid=valid
valid=valid,
description=row['comment']
))
return res
@@ -605,13 +606,18 @@ class ForeignKeyConstraintView(PGChildNodeView):
if is_error:
return errmsg
other_node_info = {}
if 'comment' in data:
other_node_info['description'] = data['comment']
return jsonify(
node=self.blueprint.generate_browser_node(
res['rows'][0]['oid'],
tid,
data['name'],
valid=valid,
icon=icon
icon=icon,
**other_node_info
)
)
@@ -713,7 +719,8 @@ class ForeignKeyConstraintView(PGChildNodeView):
tid,
name,
icon=icon,
valid=valid
valid=valid,
**other_node_info
)
)
except Exception as e:

View File

@@ -488,7 +488,8 @@ class IndexConstraintView(PGChildNodeView):
row['oid'],
tid,
row['name'],
icon=self.node_icon
icon=self.node_icon,
description=row['comment']
))
return res
@@ -625,12 +626,17 @@ class IndexConstraintView(PGChildNodeView):
self.end_transaction()
return internal_server_error(errormsg=res)
other_node_info = {}
if 'comment' in data:
other_node_info['description'] = data['comment']
return jsonify(
node=self.blueprint.generate_browser_node(
res['rows'][0]['oid'],
tid,
data['name'],
icon=self.node_icon
icon=self.node_icon,
**other_node_info
)
)
@@ -696,7 +702,8 @@ class IndexConstraintView(PGChildNodeView):
cid,
tid,
name,
icon=self.node_icon
icon=self.node_icon,
**other_node_info
)
)
except Exception as e:

View File

@@ -431,7 +431,8 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
scid,
rset['rows'][0]['name'],
icon="icon-view" if self.node_type == 'view'
else "icon-mview"
else "icon-mview",
description=rset['rows'][0]['comment']
)
return make_json_response(
@@ -459,7 +460,8 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
scid,
row['name'],
icon="icon-view" if self.node_type == 'view'
else "icon-mview"
else "icon-mview",
description=row['comment']
))
return make_json_response(
@@ -583,13 +585,18 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if not status:
return internal_server_error(errormsg=new_scid)
other_node_info = {}
if 'comment' in data:
other_node_info['description'] = data['comment']
return jsonify(
node=self.blueprint.generate_browser_node(
view_id,
new_scid,
data['name'],
icon="icon-view" if self.node_type == 'view'
else "icon-mview"
else "icon-mview",
**other_node_info
)
)
except Exception as e:
@@ -631,13 +638,18 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if not status:
return internal_server_error(errormsg=new_scid)
other_node_info = {}
if 'comment' in data:
other_node_info['description'] = data['comment']
return jsonify(
node=self.blueprint.generate_browser_node(
view_id,
new_scid,
new_view_name,
icon="icon-view" if self.node_type == 'view'
else "icon-mview"
else "icon-mview",
**other_node_info
)
)
except Exception as e:

View File

@@ -1,7 +1,9 @@
SELECT
c.oid,
c.relname AS name
c.relname AS name,
description AS comment
FROM pg_catalog.pg_class c
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass)
WHERE
c.relkind = 'm'
{% if (vid and datlastsysoid) %}

View File

@@ -1,7 +1,9 @@
SELECT
c.oid,
c.relname AS name
c.relname AS name,
description AS comment
FROM pg_catalog.pg_class c
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass)
WHERE
c.relkind = 'm'
{% if (vid and datlastsysoid) %}

View File

@@ -1,7 +1,9 @@
SELECT
c.oid,
c.relname AS name
c.relname AS name,
description AS comment
FROM pg_catalog.pg_class c
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass)
WHERE
c.relkind = 'v'
{% if (vid and datlastsysoid) %}

View File

@@ -1,7 +1,9 @@
SELECT
c.oid,
c.relname AS name
c.relname AS name,
description AS comment
FROM pg_catalog.pg_class c
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass)
WHERE
c.relkind = 'v'
{% if (vid and datlastsysoid) %}

View File

@@ -196,7 +196,8 @@ class TablespaceView(PGChildNodeView):
row['oid'],
sid,
row['name'],
icon="icon-tablespace"
icon="icon-tablespace",
description=row['description']
))
return make_json_response(
@@ -357,12 +358,17 @@ class TablespaceView(PGChildNodeView):
)
)
other_node_info = {}
if 'description' in data:
other_node_info['description'] = data['description']
return jsonify(
node=self.blueprint.generate_browser_node(
tsid,
sid,
data['name'],
icon="icon-tablespace"
icon="icon-tablespace",
**other_node_info
)
)
except Exception as e:
@@ -389,12 +395,17 @@ class TablespaceView(PGChildNodeView):
if not status:
return internal_server_error(errormsg=res)
other_node_info = {}
if 'description' in data:
other_node_info['description'] = data['description']
return jsonify(
node=self.blueprint.generate_browser_node(
tsid,
sid,
name,
icon="icon-%s" % self.node_type
icon="icon-%s" % self.node_type,
**other_node_info
)
)
except Exception as e:

View File

@@ -1,5 +1,6 @@
SELECT
ts.oid AS oid, spcname AS name, spcowner as owner
ts.oid AS oid, spcname AS name, spcowner as owner,
pg_catalog.shobj_description(oid, 'pg_tablespace') AS description
FROM
pg_catalog.pg_tablespace ts
{% if tsid %}

View File

@@ -99,8 +99,8 @@ export default function ObjectBreadcrumbs({pgAdmin}) {
<AccountTreeIcon style={{height: '1rem', marginRight: '0.125rem'}} />
<div className={classes.overflow}>
{
objectData.path?.reduce((res, item)=>(
res.concat(<span key={item}>{item}</span>, <ArrowForwardIosRoundedIcon key={item+'-arrow'} style={{height: '0.8rem', width: '1.25rem'}} />)
objectData.path?.reduce((res, item, i)=>(
res.concat(<span key={i}>{item}</span>, <ArrowForwardIosRoundedIcon key={i+'-arrow'} style={{height: '0.8rem', width: '1.25rem'}} />)
), []).slice(0, -1)
}
</div>