Hey I have another function question. Do they not ...
# help
t
Hey I have another function question. Do they not support selecting count() in them? I have a query to select count that works in the query editor, but trying to create a function for it gives me an error saying syntax error at or near SELECT. Here's the query:
Copy code
SELECT COUNT(*) as row_count
FROM public.article_comments
WHERE article_comments.article_id = 2 AND
article_comments.deleted <> true;
@User
I tried adding begin and end to it and then it does let me make it, but I get a 400 error when trying to run via the api
g
So now you probably are hitting RLS. The API checks RLS, the sql window does not.
t
ah so you need to add RLS to functions too, not just tables?
g
If you want to avoid RLS, and it is safe to do so in your function, you can use security definer to ignore RLS.
Yes on any table you use RLS but be met
t
Oh okay cool.
So was able to create the function and don't get a 400 error, but it's not returning anything to the front. I'll have to debug some more
Thank you!