Skip to content

Commit

Permalink
When comparing grants, run REVOKE commands prior to GRANT commands
Browse files Browse the repository at this point in the history
  • Loading branch information
littleK0i committed Aug 16, 2023
1 parent 92f528d commit ddbacdc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.18.2] - 2023-08-16

- When comparing grants, run `REVOKE` commands prior to `GRANT` commands. It should help to resolve issues with `OWNERSHIP` future grant, which should be revoked before a new `OWNERSHIP` grant can be added.

## [0.18.1] - 2023-07-26

- Ignore grants for object types which are currently not supported by SnowDDL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ text: |-
FROM ${{ env_prefix }}test_db.test_schema.test_table_1
GROUP BY 1
target_lag: 1 minute
target_lag: 1 hour
warehouse: dynamic_table_wh
18 changes: 9 additions & 9 deletions snowddl/resolver/abc_role_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,20 @@ def compare_object(self, bp: RoleBlueprint, row: dict):

result = ResolveResult.ALTER

for existing_grant in row['grants']:
if existing_grant not in bp.grants \
and self.grant_to_future_grant(existing_grant) not in bp.future_grants:
self.drop_grant(bp.full_name, existing_grant)
result = ResolveResult.GRANT

for bp_grant in bp.grants:
if bp_grant not in row['grants']:
self.create_grant(bp.full_name, bp_grant)
result = ResolveResult.GRANT

for existing_grant in row['grants']:
if existing_grant not in bp.grants \
and self.grant_to_future_grant(existing_grant) not in bp.future_grants:
self.drop_grant(bp.full_name, existing_grant)
for existing_future_grant in row['future_grants']:
if existing_future_grant not in bp.future_grants:
self.drop_future_grant(bp.full_name, existing_future_grant)
result = ResolveResult.GRANT

for bp_future_grant in bp.future_grants:
Expand All @@ -146,11 +151,6 @@ def compare_object(self, bp: RoleBlueprint, row: dict):
self.refresh_future_grant(bp.full_name, bp_future_grant)
result = ResolveResult.GRANT

for existing_future_grant in row['future_grants']:
if existing_future_grant not in bp.future_grants:
self.drop_future_grant(bp.full_name, existing_future_grant)
result = ResolveResult.GRANT

return result

def drop_object(self, row: dict):
Expand Down
2 changes: 1 addition & 1 deletion snowddl/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.18.1'
__version__ = '0.18.2'

0 comments on commit ddbacdc

Please sign in to comment.