提问人:niepl 提问时间:11/5/2023 更新时间:11/5/2023 访问量:35
如何创建具有条件限制的策略Postgres?
how to create a policy postgres with conditional limit with conditional?
问:
之前我制定了能够获取所有数据的角色的策略,但我不希望他们获取所有数据,所以我想通过限制来限制它们
我以前的政策是这样的
CREATE POLICY "Account profiles are viewable by himself."
ON public.accounts
AS PERMISSIVE
FOR SELECT
TO anon, authenticated, cms-admin
USING (true);
当我尝试这样时:
CREATE POLICY "Account profiles are viewable by himself."
ON public.accounts
AS PERMISSIVE
FOR SELECT
TO anon, authenticated, cms-admin
USING (LIMIT 5);
我收到错误:
ERROR: syntax error at or near "LIMIT"
LINE 7: WITH CHECK (LIMIT 5);
^
SQL state: 42601
Character: 172
我也想使用这个条件策略
ORDER BY id DESC
LIMIT CASE WHEN current_setting('role', true)::text IN (anon, authenticated) THEN 1 END;
是否可以在策略上运行上述条件?
答: 暂无答案
评论