Repository navigation
fix: render per-privilege column lists in grants (#638) #661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shehjaddev
wants to merge
2
commits into
pgplex:main
Choose a base branch
from
shehjaddev:fix/issue-638-column-privileges
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
testdata/diff/privilege/issue_638_multi_privilege_column_grant/diff.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| REVOKE INSERT (a, b), UPDATE (a, b) ON TABLE t FROM app_user; | ||
|
|
||
| GRANT INSERT (x), UPDATE (x) ON TABLE u TO app_user; | ||
|
|
||
| GRANT INSERT (c), UPDATE (c) ON TABLE v TO app_user WITH GRANT OPTION; | ||
|
|
||
| REVOKE GRANT OPTION FOR INSERT (c), UPDATE (c) ON TABLE w FROM app_user; | ||
|
|
||
| GRANT INSERT (a), UPDATE (a) ON TABLE t TO app_user; |
22 changes: 22 additions & 0 deletions
22
testdata/diff/privilege/issue_638_multi_privilege_column_grant/new.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| DO $$ | ||
| BEGIN | ||
| IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'app_user') THEN | ||
| CREATE ROLE app_user; | ||
| END IF; | ||
| END $$; | ||
|
|
||
| CREATE TABLE t (id int PRIMARY KEY, a int, b int); | ||
|
|
||
| CREATE TABLE u (id int PRIMARY KEY, x int); | ||
|
|
||
| CREATE TABLE v (id int PRIMARY KEY, c int); | ||
|
|
||
| CREATE TABLE w (id int PRIMARY KEY, c int); | ||
|
|
||
| GRANT INSERT (a), UPDATE (a) ON t TO app_user; | ||
|
|
||
| GRANT INSERT (x), SELECT (x), UPDATE (x) ON u TO app_user; | ||
|
|
||
| GRANT INSERT (c), UPDATE (c) ON v TO app_user WITH GRANT OPTION; | ||
|
|
||
| GRANT INSERT (c), UPDATE (c) ON w TO app_user; | ||
22 changes: 22 additions & 0 deletions
22
testdata/diff/privilege/issue_638_multi_privilege_column_grant/old.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| DO $$ | ||
| BEGIN | ||
| IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'app_user') THEN | ||
| CREATE ROLE app_user; | ||
| END IF; | ||
| END $$; | ||
|
|
||
| CREATE TABLE t (id int PRIMARY KEY, a int, b int); | ||
|
|
||
| CREATE TABLE u (id int PRIMARY KEY, x int); | ||
|
|
||
| CREATE TABLE v (id int PRIMARY KEY, c int); | ||
|
|
||
| CREATE TABLE w (id int PRIMARY KEY, c int); | ||
|
|
||
| GRANT INSERT (a, b), UPDATE (a, b) ON t TO app_user; | ||
|
|
||
| GRANT SELECT (x) ON u TO app_user; | ||
|
|
||
| GRANT INSERT (c), UPDATE (c) ON v TO app_user; | ||
|
|
||
| GRANT INSERT (c), UPDATE (c) ON w TO app_user WITH GRANT OPTION; |
44 changes: 44 additions & 0 deletions
44
testdata/diff/privilege/issue_638_multi_privilege_column_grant/plan.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| { | ||
| "version": "1.0.0", | ||
| "pgschema_version": "1.13.3", | ||
| "created_at": "1970-01-01T00:00:00Z", | ||
| "source_fingerprint": { | ||
| "hash": "ca8fed2741083ff2d176cec3b66b587bcf4d1a0d50c25519579134aaa173c093" | ||
| }, | ||
| "groups": [ | ||
| { | ||
| "steps": [ | ||
| { | ||
| "sql": "REVOKE INSERT (a, b), UPDATE (a, b) ON TABLE t FROM app_user;", | ||
| "type": "column_privilege", | ||
| "operation": "drop", | ||
| "path": "column_privileges.TABLE.t.a,b.app_user" | ||
| }, | ||
| { | ||
| "sql": "GRANT INSERT (x), UPDATE (x) ON TABLE u TO app_user;", | ||
| "type": "column_privilege", | ||
| "operation": "alter", | ||
| "path": "column_privileges.TABLE.u.x.app_user" | ||
| }, | ||
| { | ||
| "sql": "GRANT INSERT (c), UPDATE (c) ON TABLE v TO app_user WITH GRANT OPTION;", | ||
| "type": "column_privilege", | ||
| "operation": "alter", | ||
| "path": "column_privileges.TABLE.v.c.app_user" | ||
| }, | ||
| { | ||
| "sql": "REVOKE GRANT OPTION FOR INSERT (c), UPDATE (c) ON TABLE w FROM app_user;", | ||
| "type": "column_privilege", | ||
| "operation": "alter", | ||
| "path": "column_privileges.TABLE.w.c.app_user" | ||
| }, | ||
| { | ||
| "sql": "GRANT INSERT (a), UPDATE (a) ON TABLE t TO app_user;", | ||
| "type": "column_privilege", | ||
| "operation": "create", | ||
| "path": "column_privileges.TABLE.t.a.app_user" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
9 changes: 9 additions & 0 deletions
9
testdata/diff/privilege/issue_638_multi_privilege_column_grant/plan.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| REVOKE INSERT (a, b), UPDATE (a, b) ON TABLE t FROM app_user; | ||
|
|
||
| GRANT INSERT (x), UPDATE (x) ON TABLE u TO app_user; | ||
|
|
||
| GRANT INSERT (c), UPDATE (c) ON TABLE v TO app_user WITH GRANT OPTION; | ||
|
|
||
| REVOKE GRANT OPTION FOR INSERT (c), UPDATE (c) ON TABLE w FROM app_user; | ||
|
|
||
| GRANT INSERT (a), UPDATE (a) ON TABLE t TO app_user; |
24 changes: 24 additions & 0 deletions
24
testdata/diff/privilege/issue_638_multi_privilege_column_grant/plan.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| Plan: 1 to add, 3 to modify, 1 to drop. | ||
|
|
||
| Summary by type: | ||
| column privileges: 1 to add, 3 to modify, 1 to drop | ||
|
|
||
| Column privileges: | ||
| - app_user | ||
| + app_user | ||
| ~ app_user | ||
| ~ app_user | ||
| ~ app_user | ||
|
|
||
| DDL to be executed: | ||
| -------------------------------------------------- | ||
|
|
||
| REVOKE INSERT (a, b), UPDATE (a, b) ON TABLE t FROM app_user; | ||
|
|
||
| GRANT INSERT (x), UPDATE (x) ON TABLE u TO app_user; | ||
|
|
||
| GRANT INSERT (c), UPDATE (c) ON TABLE v TO app_user WITH GRANT OPTION; | ||
|
|
||
| REVOKE GRANT OPTION FOR INSERT (c), UPDATE (c) ON TABLE w FROM app_user; | ||
|
|
||
| GRANT INSERT (a), UPDATE (a) ON TABLE t TO app_user; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new regression covers creating, dropping, and adding column privileges, but not the changed grant-option branches. Existing grant-option fixtures use table privileges, so they would not catch a regression in these column-specific statements. Add cases with multiple privileges on the same columns that add and remove
WITH GRANT OPTION.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!