From 3cab45e8b7d31fa7ea07adef70d0404567d91f7a Mon Sep 17 00:00:00 2001 From: Fraser Barton Date: Fri, 6 Oct 2023 10:44:19 +0100 Subject: [PATCH 1/5] add adapter quote --- .../include/global_project/macros/adapters/apply_grants.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/dbt/include/global_project/macros/adapters/apply_grants.sql b/core/dbt/include/global_project/macros/adapters/apply_grants.sql index 10906e7ffa7..6be8e44d9cc 100644 --- a/core/dbt/include/global_project/macros/adapters/apply_grants.sql +++ b/core/dbt/include/global_project/macros/adapters/apply_grants.sql @@ -79,7 +79,11 @@ {% endmacro %} {%- macro default__get_revoke_sql(relation, privilege, grantees) -%} - revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }} + revoke {{ privilege }} on {{ relation }} from + {% for grantee in grantees %} + {{ adapter.quote(grantee) }} + {% if not loop.last %},{% endif %} + {% endfor %} {%- endmacro -%} From ee1c72be8b0b7f1ba017d792d2373340f28e14e2 Mon Sep 17 00:00:00 2001 From: Fraser Barton Date: Fri, 6 Oct 2023 13:19:08 +0100 Subject: [PATCH 2/5] Update default__get_grant_sql --- .../include/global_project/macros/adapters/apply_grants.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/dbt/include/global_project/macros/adapters/apply_grants.sql b/core/dbt/include/global_project/macros/adapters/apply_grants.sql index 6be8e44d9cc..66b617264ad 100644 --- a/core/dbt/include/global_project/macros/adapters/apply_grants.sql +++ b/core/dbt/include/global_project/macros/adapters/apply_grants.sql @@ -70,7 +70,11 @@ {% endmacro %} {%- macro default__get_grant_sql(relation, privilege, grantees) -%} - grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }} + grant {{ privilege }} on {{ relation }} to + {% for grantee in grantees %} + {{ adapter.quote(grantee) }} + {% if not loop.last %},{% endif %} + {% endfor %} {%- endmacro -%} From 00d1d4e27b3a87f4cf5c835cbac39955dab06fde Mon Sep 17 00:00:00 2001 From: Fraser Barton Date: Fri, 6 Oct 2023 14:14:55 +0100 Subject: [PATCH 3/5] update changelog --- .changes/unreleased/Fixes-20231006-141430.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Fixes-20231006-141430.yaml diff --git a/.changes/unreleased/Fixes-20231006-141430.yaml b/.changes/unreleased/Fixes-20231006-141430.yaml new file mode 100644 index 00000000000..e9216704787 --- /dev/null +++ b/.changes/unreleased/Fixes-20231006-141430.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: 'Add quotes to usernames when revoking and granting permissions. Resolves issues + #6444 and #8751' +time: 2023-10-06T14:14:30.472821+01:00 +custom: + Author: barton996 + Issue: 6444 8751 From f4b0cf6f7ebb5c3e9ec80597cb1c5f85ff2a26d1 Mon Sep 17 00:00:00 2001 From: Fraser Barton Date: Fri, 6 Oct 2023 14:23:06 +0100 Subject: [PATCH 4/5] trigger CI --- .../dbt/include/global_project/macros/adapters/apply_grants.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/include/global_project/macros/adapters/apply_grants.sql b/core/dbt/include/global_project/macros/adapters/apply_grants.sql index 66b617264ad..8a81fda8cac 100644 --- a/core/dbt/include/global_project/macros/adapters/apply_grants.sql +++ b/core/dbt/include/global_project/macros/adapters/apply_grants.sql @@ -1,7 +1,7 @@ {# ------- BOOLEAN MACROS --------- #} {# - -- COPY GRANTS + -- COPY GRANTS. -- When a relational object (view or table) is replaced in this database, -- do previous grants carry over to the new object? This may depend on: -- whether we use alter-rename-swap versus CREATE OR REPLACE From 5196d88eb05924221219b2515d6654efbb466bde Mon Sep 17 00:00:00 2001 From: Fraser Barton Date: Fri, 6 Oct 2023 16:36:23 +0100 Subject: [PATCH 5/5] remove period --- .../dbt/include/global_project/macros/adapters/apply_grants.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/include/global_project/macros/adapters/apply_grants.sql b/core/dbt/include/global_project/macros/adapters/apply_grants.sql index 8a81fda8cac..66b617264ad 100644 --- a/core/dbt/include/global_project/macros/adapters/apply_grants.sql +++ b/core/dbt/include/global_project/macros/adapters/apply_grants.sql @@ -1,7 +1,7 @@ {# ------- BOOLEAN MACROS --------- #} {# - -- COPY GRANTS. + -- COPY GRANTS -- When a relational object (view or table) is replaced in this database, -- do previous grants carry over to the new object? This may depend on: -- whether we use alter-rename-swap versus CREATE OR REPLACE