mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-24 15:26:46 -06:00
Resolving an error related to not able to generate the reversed
engineered SQL from the database when no ACL is defined.
This commit is contained in:
parent
a82f58a8f4
commit
712f47987f
@ -636,7 +636,8 @@ class DatabaseView(NodeView):
|
||||
if arg not in data:
|
||||
return " -- definition incomplete"
|
||||
# Privileges
|
||||
data['datacl'] = parse_priv_to_db(data['datacl'], 'DATABASE')
|
||||
if 'datacl' in data:
|
||||
data['datacl'] = parse_priv_to_db(data['datacl'], 'DATABASE')
|
||||
|
||||
# Default privileges
|
||||
for key in ['deftblacl', 'defseqacl', 'deffuncacl', 'deftypeacl']:
|
||||
@ -692,39 +693,36 @@ class DatabaseView(NodeView):
|
||||
"""
|
||||
This function will generate sql for sql panel
|
||||
"""
|
||||
try:
|
||||
SQL = render_template("/".join([self.template_path, 'properties.sql']), did=did)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
SQL = render_template("/".join([self.template_path, 'properties.sql']), did=did)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
SQL = render_template("/".join([self.template_path, 'acl.sql']), did=did)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
res = self.formatdbacl(res, dataclres['rows'])
|
||||
SQL = render_template("/".join([self.template_path, 'acl.sql']), did=did)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
res = self.formatdbacl(res, dataclres['rows'])
|
||||
|
||||
SQL = render_template("/".join([self.template_path, 'defacl.sql']), did=did)
|
||||
status, defaclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
SQL = render_template("/".join([self.template_path, 'defacl.sql']), did=did)
|
||||
status, defaclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
res = self.formatdbacl(res, defaclres['rows'])
|
||||
res = self.formatdbacl(res, defaclres['rows'])
|
||||
|
||||
result = res['rows'][0]
|
||||
result = res['rows'][0]
|
||||
|
||||
SQL = render_template("/".join([self.template_path, 'get_variables.sql']), did=did)
|
||||
status, res1 = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res1)
|
||||
SQL = render_template("/".join([self.template_path, 'get_variables.sql']), did=did)
|
||||
status, res1 = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res1)
|
||||
|
||||
frmtd_reslt = self.formatter(result, res1)
|
||||
result.update(frmtd_reslt)
|
||||
frmtd_reslt = self.formatter(result, res1)
|
||||
result.update(frmtd_reslt)
|
||||
|
||||
SQL = self.getNewSQL(gid, sid, result, did)
|
||||
return ajax_response(response=SQL)
|
||||
SQL = self.getNewSQL(gid, sid, result, did)
|
||||
|
||||
except Exception as e:
|
||||
return ajax_response(response=str(e))
|
||||
return ajax_response(response=SQL)
|
||||
|
||||
DatabaseView.register_node_view(blueprint)
|
||||
|
@ -1,4 +1,4 @@
|
||||
SELECT 'datacl' as deftype, COALESCE(gt.rolname, 'public') grantee, g.rolname grantor, array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
|
||||
SELECT 'datacl' AS deftype, COALESCE(gt.rolname, 'public') AS grantee, g.rolname AS grantor, array_agg(privilege_type) AS privileges, array_agg(is_grantable) AS grantable
|
||||
FROM
|
||||
(SELECT
|
||||
d.grantee, d.grantor, d.is_grantable,
|
||||
@ -30,4 +30,4 @@ FROM
|
||||
) d
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
|
||||
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
|
||||
GROUP BY g.rolname, gt.rolname
|
||||
GROUP BY g.rolname, gt.rolname
|
||||
|
@ -5,7 +5,7 @@ SELECT
|
||||
WHEN 'f' THEN 'deffuncacl'
|
||||
WHEN 'T' THEN 'deftypeacl'
|
||||
END AS deftype,
|
||||
COALESCE(gt.rolname, 'public') grantee, g.rolname grantor, array_agg(a.privilege_type) as privileges, array_agg(a.is_grantable) as grantable
|
||||
COALESCE(gt.rolname, 'public') AS grantee, g.rolname AS grantor, array_agg(a.privilege_type) as privileges, array_agg(a.is_grantable) as grantable
|
||||
FROM
|
||||
(SELECT
|
||||
(acl).grantee as grantee, (acl).grantor AS grantor, (acl).is_grantable AS is_grantable,
|
||||
@ -31,4 +31,4 @@ FROM
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid)
|
||||
LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid)
|
||||
GROUP BY g.rolname, gt.rolname, a.deftype
|
||||
ORDER BY a.deftype
|
||||
ORDER BY a.deftype
|
||||
|
Loading…
Reference in New Issue
Block a user