diff --git a/.changes/unreleased/Fixes-20231010-193527.yaml b/.changes/unreleased/Fixes-20231010-193527.yaml new file mode 100644 index 00000000000..960970e842e --- /dev/null +++ b/.changes/unreleased/Fixes-20231010-193527.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Add quotes to usernames when revoking and granting table permissions +time: 2023-10-10T19:35:27.223761+01:00 +custom: + Author: barton996 + Issue: 6444 8751 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..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 -%} @@ -79,7 +83,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 -%}