dbt-labs / dbt-labs/dbt-adapters
[CT-1661] [Bug] Grants fails to correctly quote username when revoking
- Dominant language
- Python
- Stars
- 233
- Forks
- 362
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 9
Description
### Is this a new bug in dbt-core?
- [X] I believe this is a new bug in dbt-core
- [X] I have searched the existing issues, and I could not find an existing issue for this bug
### Current Behavior
As part of the new grants feature, https://docs.getdbt.com/reference/resource-configs/grants dbt will attempt to revoke users not part of the grant before reapplying users listed in the grant.
DBT does this (at least in the Redshift adaptor ) by pulling the table permissions and explicitly looping through every user then using a revoke command like
revoke select on "database"."schema"."table" from user1, user2 ;
The user is not quoted so a user like user.name will fail with
syntax error at or near "."
LINE 2: ...user1, user.name, user2...
I am fairly certain the macro in https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/include/global_project/macros/adapters/apply_grants.sql line 82 just needs some quotes
### Expected Behavior
the revoke command should quote users
revoke select on "database"."schema"."table" from "user1", "user2" ;
### Steps To Reproduce
Create a user with a period in the name for example in Redshift
create user "first.last";
Create a simple dbt incremental model and user the grant syntax to give permission to that table within dbt.
Run DBT twice (on the first run the revoke macro is not run as the table is new)
### Relevant log output
_No response_
### Environment
```markdown
- OS:Ubuntu 20.04
- Python: 3.8.10
- dbt: 1.3.1
```
### Which database adapter are you using with dbt?
redshift
### Additional Context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.