-
-
Save ryanguill/b1ae32337b458f830990133187178798 to your computer and use it in GitHub Desktop.
This file contains 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
begin; | |
create table foo ( | |
id uuid primary key not null, | |
updatable text, | |
not_updatable text | |
); | |
create user test_user; | |
GRANT insert on foo TO test_user; | |
GRANT select on foo TO test_user; | |
revoke update on foo from test_user; | |
grant update (updatable) on foo to test_user; | |
set role test_user; | |
select * from foo; | |
insert into foo (id, updatable, not_updatable) | |
values ('00000000-0000-0000-0000000000000001', 'original', 'original'); | |
select * from foo; | |
update foo | |
set updatable = 'updated' | |
where id = '00000000-0000-0000-0000000000000001'; | |
select * from foo; | |
update foo | |
set not_updatable = 'updated' | |
where id = '00000000-0000-0000-0000000000000001'; | |
-- permission denied for table foo | |
update foo | |
set id = '00000000-0000-0000-0000000000000002' | |
where id = '00000000-0000-0000-0000000000000001'; | |
-- permission denied for table foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment