stibbs
10/20/2021, 9:03 PMmikebarkmin
10/20/2021, 9:18 PMinfinite recursion detected in policy for relation "conversation_users"
on inserting to conversation_users. I thought creating a security definer function would solve this, but it did not. Does anybody has an idea?
sql
CREATE OR REPLACE FUNCTION get_conversation_users_for_authenticated_user()
returns setof uuid
language sql
security definer
set search_path = public
stable
as $$
SELECT DISTINCT user_id FROM conversation_users WHERE conversation_id IN (
SELECT DISTINCT conversation_id FROM conversation_users WHERE user_id = auth.uid()
)
$$;
CREATE POLICY "Can select conversation_users" ON public.conversation_users AS PERMISSIVE FOR
SELECT TO public USING (
user_id IN (
SELECT get_conversation_users_for_authenticated_user()
)
);
CREATE POLICY "Can update to conversation_users" ON public.conversation_users AS PERMISSIVE FOR
UPDATE To public USING (
conversation_id IN (SELECT id FROM conversations WHERE admin_id = auth.uid())
) WITH CHECK (
conversation_id IN (SELECT id FROM conversations WHERE admin_id = auth.uid())
);
CREATE POLICY "Can insert to conversation_users" ON public.conversation_users AS PERMISSIVE FOR
INSERT To public WITH CHECK (
conversation_id IN (SELECT id FROM conversations WHERE admin_id = auth.uid())
);
CREATE POLICY "Can delete from conversation_users" ON public.conversation_users AS PERMISSIVE FOR
DELETE TO public USING (
(conversation_id IN (SELECT id FROM conversations WHERE admin_id = auth.uid()))
OR (user_id = auth.uid())
);
jason-lynx
10/21/2021, 2:53 AMeasystreet
10/21/2021, 8:32 PMstibbs
10/24/2021, 9:00 AMto_tsvector()
cache the document (table?) for some period? I have the below query. I ran it and correctly got 3 results. I then updated one of the rows to set closed = true
and correctly got 2 results. I then updated that row back to closed = false
and still only get 2 results??
sql
select *
from public.jobs j
where j.closed = false
and j.valid_until > now()
and to_tsvector(j.business_name) || ' ' ||
array_to_tsvector(j.categories)
@@ plainto_tsquery('demand');
stibbs
10/24/2021, 9:05 AMj.closed
and j.valid_until
checks it still only gives 2 results... hmmmstibbs
10/24/2021, 9:09 AMstibbs
10/24/2021, 11:28 AMto_tsvector
stibbs
10/24/2021, 11:34 AMcoalesce
a fieldMattias
10/25/2021, 8:54 AMferminrp
10/25/2021, 12:59 PMferminrp
10/25/2021, 12:59 PMferminrp
10/25/2021, 1:00 PMferminrp
10/25/2021, 1:00 PMferminrp
10/25/2021, 1:03 PMsilentworks
10/25/2021, 1:35 PMM1K3
10/25/2021, 4:22 PMThomas B
10/25/2021, 4:24 PMM1K3
10/25/2021, 4:24 PMM1K3
10/25/2021, 4:24 PMM1K3
10/25/2021, 4:25 PMM1K3
10/25/2021, 4:25 PMM1K3
10/25/2021, 4:26 PMThomas B
10/25/2021, 4:26 PMM1K3
10/25/2021, 4:26 PMM1K3
10/25/2021, 4:27 PMM1K3
10/25/2021, 4:31 PMThomas B
10/25/2021, 4:42 PMstibbs
10/26/2021, 9:02 AMHarryET
10/26/2021, 10:42 AM