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 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 -%}