mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Update "parse_priv_to_db" function to return list a instead of a string.
This will also allow us to operate on individual privileges & also we
needed this functionality for column nodes.
For example,
*Earlier:* priv was string
GRANT {{ priv }} ON {{ type }} TO {{ conn|qtIdent(role) }};
*Now:* priv will be List, which we need to handle in jinja templates.
GRANT *{{ priv|join(', ') }}* ON {{ type }} TO {{ conn|qtIdent(role) }};
This commit is contained in:
committed by
Dave Page
parent
5d6c5bc74d
commit
8a7ec6b452
@@ -1,11 +1,11 @@
|
||||
{% macro APPLY(conn, type, role, priv, with_grant) -%}
|
||||
{% if priv %}
|
||||
{% macro APPLY(conn, type, role, privs, with_grant_privs) -%}
|
||||
{% if privs %}
|
||||
ALTER DEFAULT PRIVILEGES
|
||||
GRANT {{ priv }} ON {{ type }} TO {{ conn|qtIdent(role) }};
|
||||
GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }};
|
||||
{% endif %}
|
||||
{% if with_grant %}
|
||||
{% if with_grant_privs %}
|
||||
ALTER DEFAULT PRIVILEGES
|
||||
GRANT {{ with_grant }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
|
||||
GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
{% macro RESETALL(conn, type, role) -%}
|
||||
@@ -13,14 +13,14 @@ ALTER DEFAULT PRIVILEGES
|
||||
REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }};
|
||||
{%- endmacro %}
|
||||
{### To allow create macro for specific database object ###}
|
||||
{% macro SET(conn, db_object_type, db_object_name, type, role, priv, with_grant) -%}
|
||||
{% if priv %}
|
||||
{% macro SET(conn, db_object_type, db_object_name, type, role, privs, with_grant_privs) -%}
|
||||
{% if privs %}
|
||||
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
|
||||
GRANT {{ priv }} ON {{ type }} TO {{ conn|qtIdent(role) }};
|
||||
GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }};
|
||||
{% endif %}
|
||||
{% if with_grant %}
|
||||
{% if with_grant_privs %}
|
||||
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
|
||||
GRANT {{ with_grant }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
|
||||
GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
{% macro UNSET(conn, db_object_type, db_object_name, type, role) -%}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{% macro APPLY(conn, type, role, param, priv, with_grant) -%}
|
||||
{% if priv %}
|
||||
GRANT {{ priv }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }};
|
||||
{% macro APPLY(conn, type, role, param, privs, with_grant_privs) -%}
|
||||
{% if privs %}
|
||||
GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }};
|
||||
{% endif %}
|
||||
{% if with_grant %}
|
||||
GRANT {{ with_grant }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
|
||||
{% if with_grant_privs %}
|
||||
GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
{% macro RESETALL(conn, type, role, param) -%}
|
||||
|
||||
Reference in New Issue
Block a user