我需要撤销 test.persons 表中 uid 列的 INSERT 和 UPDATE 权限。
以下是我目前所做的:
CREATE TABLE test.persons (
uid UUID DEFAULT gen_random_uuid() PRIMARY KEY,
name VARCHAR(255),
description TEXT
);
REVOKE INSERT (uid) ON test.persons FROM hasura;
GRANT INSERT (name, description) ON test.persons TO hasura;
REVOKE UPDATE (uid) ON test.persons FROM hasura;
GRANT UPDATE (name, description) ON test.persons TO hasura;
INSERT INTO test.persons (uid, name, description)
VALUES ('e7443661-f6c3-4448-8df7-c65e3f8243ca', 'John Doe', 'Some description');
//correct: ERROR: permission denied for table persons
INSERT INTO test.persons (uid)
VALUES (gen_random_uuid());
//correct: ERROR: permission denied for table persons
INSERT INTO test.persons (name, description)
VALUES ('John Doe', 'Some description');
//correct: Successfully inserted
INSERT INTO test.persons (name)
VALUES ('John Doe1');
//correct: Successfully inserted
到目前为止,一切都很好。
但是当我尝试执行以下更新时:
UPDATE test.persons SET uid = gen_random_uuid() WHERE name = 'John Doe';
它已成功更新,但实际上不应该更新,因为我撤销了 uid 列上的 UPDATE 权限。
我做错了什么以及我应该如何正确地撤销 uid 列上的 UPDATE 权限?