Make the default privileges jinja2 template macros to generate more

consistent SQL.
i.e.
Put 4 spaces after every new line (wherever required).
This commit is contained in:
Ashesh Vashi
2016-02-28 12:06:21 +05:30
parent d4a13eaafa
commit 41e85fd631

View File

@@ -1,11 +1,11 @@
{% macro APPLY(conn, type, role, priv, with_grant) -%} {% macro APPLY(conn, type, role, priv, with_grant) -%}
{% if priv %} {% if priv %}
ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES
GRANT {{ priv }} ON {{ type }} TO {{ conn|qtIdent(role) }}; GRANT {{ priv }} ON {{ type }} TO {{ conn|qtIdent(role) }};
{% endif %} {% endif %}
{% if with_grant %} {% if with_grant %}
ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES
GRANT {{ with_grant }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION; GRANT {{ with_grant }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
{% macro RESETALL(conn, type, role) -%} {% macro RESETALL(conn, type, role) -%}
@@ -16,14 +16,14 @@ ALTER DEFAULT PRIVILEGES
{% macro SET(conn, db_object_type, db_object_name, type, role, priv, with_grant) -%} {% macro SET(conn, db_object_type, db_object_name, type, role, priv, with_grant) -%}
{% if priv %} {% if priv %}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }} ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
GRANT {{ priv }} ON {{ type }} TO {{ conn|qtIdent(role) }}; GRANT {{ priv }} ON {{ type }} TO {{ conn|qtIdent(role) }};
{% endif %} {% endif %}
{% if with_grant %} {% if with_grant %}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }} 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 }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
{% macro UNSET(conn, db_object_type, db_object_name, type, role) -%} {% macro UNSET(conn, db_object_type, db_object_name, type, role) -%}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }} ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }}; REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }};
{%- endmacro %} {%- endmacro %}