From 3ea4228e5042c40234bb857338e3cd0e2ea410ae Mon Sep 17 00:00:00 2001 From: mp24-git Date: Thu, 26 Jan 2023 11:21:05 +0100 Subject: [PATCH 1/2] Add grant and revoke macro overrides which add quotes around grantees --- .../redshift/macros/adapters/apply_grants.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dbt/include/redshift/macros/adapters/apply_grants.sql b/dbt/include/redshift/macros/adapters/apply_grants.sql index fa6523a26..9bb208676 100644 --- a/dbt/include/redshift/macros/adapters/apply_grants.sql +++ b/dbt/include/redshift/macros/adapters/apply_grants.sql @@ -25,3 +25,21 @@ where has_table_privilege(u.usename, '{{ relation }}', privilege_type) and not u.usesuper {% endmacro %} + + +{%- macro redshift__get_grant_sql(relation, privilege, grantees) -%} + grant {{ privilege }} on {{ relation }} to + {% for grantee in grantees %} + {{ adapter.quote(grantee) }} + {% if not loop.last %},{% endif %} + {% endfor %} +{%- endmacro -%} + + +{%- macro redshift__get_revoke_sql(relation, privilege, grantees) -%} + revoke {{ privilege }} on {{ relation }} from + {% for grantee in grantees %} + {{ adapter.quote(grantee) }} + {% if not loop.last %},{% endif %} + {% endfor %} +{%- endmacro -%} From 2e41c3fbf0b74cedce091667ba4b1de104e97574 Mon Sep 17 00:00:00 2001 From: mp24-git Date: Thu, 26 Jan 2023 11:26:50 +0100 Subject: [PATCH 2/2] Add changelog entry --- .changes/unreleased/Fixes-20230126-112628.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Fixes-20230126-112628.yaml diff --git a/.changes/unreleased/Fixes-20230126-112628.yaml b/.changes/unreleased/Fixes-20230126-112628.yaml new file mode 100644 index 000000000..2d97d5bbd --- /dev/null +++ b/.changes/unreleased/Fixes-20230126-112628.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Fix grant and revoke for Redshift grantees containing special characters +time: 2023-01-26T11:26:28.9178898+01:00 +custom: + Author: mp24-git + Issue: "277" + PR: "282"