https://supabase.com/ logo
Join Discord
Powered by
# sql
  • r

    RichCorbs

    08/28/2021, 2:48 AM
    Did you create your own policy from scratch or apply one of the templates?
  • a

    assistattow

    08/28/2021, 2:49 AM
    I used the template but changed the column name to match mine
  • a

    assistattow

    08/28/2021, 2:49 AM
    I wonder if its my actual function for deleting
  • r

    RichCorbs

    08/28/2021, 2:50 AM
    ah, something could be happening in javascript and it's not hitting supabase?
  • a

    assistattow

    08/28/2021, 2:50 AM
    it works with no security but maybe it isn't sending the right info to supabase
  • a

    assistattow

    08/28/2021, 2:50 AM
    I'm using dart but its very similarly structured
  • r

    RichCorbs

    08/28/2021, 2:51 AM
    currentUser!.id
    <--- is that dart syntax with the
    !
    ?
  • r

    RichCorbs

    08/28/2021, 2:52 AM
    LOL, we're working on similar projects.
  • a

    assistattow

    08/28/2021, 2:52 AM
    yeah, the ! is a null check
  • a

    assistattow

    08/28/2021, 2:52 AM
    its basically saying that currentUser will never be null
  • a

    assistattow

    08/28/2021, 2:52 AM
    I know it isn't null because it works when RLS is disabled
  • r

    RichCorbs

    08/28/2021, 2:52 AM
    Is currentUser non null?
  • a

    assistattow

    08/28/2021, 2:53 AM
    I feel like maybe I'm missing a query that sends the id
  • r

    RichCorbs

    08/28/2021, 2:53 AM
    if the only difference is enabling/disabling RLS then it appears to be the configuration somehow?
  • a

    assistattow

    08/28/2021, 2:53 AM
    so its checking the row but it isnt verifying im signed in
  • a

    assistattow

    08/28/2021, 2:53 AM
    yeah so it works if its disabled
  • a

    assistattow

    08/28/2021, 2:53 AM
    but it doesnt if its enabled
  • a

    assistattow

    08/28/2021, 2:54 AM
    and my policy seems to be correct so it must be the dart code
  • r

    RichCorbs

    08/28/2021, 2:54 AM
    do you also need to send the id of the duplicate record?
  • r

    RichCorbs

    08/28/2021, 2:55 AM
    in javascript I have to "await" any async calls to supabase do you have to do that in dart?
  • r

    RichCorbs

    08/28/2021, 2:56 AM
    What I'm saying is that there is no await on the call to supabase.auth.user() like on the delete so the delete might run before supabase.auth.user() has finished?
  • a

    assistattow

    08/28/2021, 2:58 AM
    so the tables called userworkouts_duplicate just because I don't want to delete my actual data when testing. In dart you can await async calls which I am doing. After final response it has the await tag and its an async function
  • a

    assistattow

    08/28/2021, 2:58 AM
    dart is essentially just JS with a few differences
  • a

    assistattow

    08/28/2021, 2:59 AM
    atleast that I have found so far
  • b

    burggraf

    08/28/2021, 2:59 AM
    Guys can you make a thread here so it’s easier to follow this discussion?
  • a

    assistattow

    08/28/2021, 2:59 AM
    yes sorry
    r
    b
    h
    • 4
    • 139
  • p

    Peanut

    08/28/2021, 3:50 AM
    Can anyone help me with this policy?
    Copy code
    CREATE POLICY "Only members of the parent conversation can see its private messages."
        ON privatemessages
        FOR SELECT USING (
            auth.uid() = ANY(
            array_agg
                (
                    (SELECT members FROM conversations WHERE conversations.id = privatemessages.id)
                )
            )
        );
    Error is
    aggregate functions are not allowed in policy expressions
  • b

    burggraf

    08/28/2021, 4:10 AM
    I have to run now, but I would write a separate function for this then just call the function from inside my policy.
  • p

    Peanut

    08/28/2021, 4:11 AM
    Good idea - will try
  • p

    Peanut

    08/28/2021, 7:29 AM
    Works! Ta!
1...111213...52Latest