I'm guessing it doesn't know what the Id we're try...
# help
w
I'm guessing it doesn't know what the Id we're trying to insert is.. but what's the point of rls if you can't check before inserting!
g
This (and the example above it) might help:
you have access to the inserted data on check so shopID gets you that value
w
Firstly thanks for helping @garyaustin - I tried something like shopID IN (SELECT shopID FROM shop_access WHERE userID = uid()) and still no luck . Seems very odd! Really not sure why it doesn't work
g
Do you have RLS on shop_access and if so select access for uid?
w
Yeh! But the way your saying this makes me think I need to persevere, must be something basic going on
I'm guessing you've done this before right, I'm not making up an anti pattern of postgre or something?
g
I use the security definer function route myself, but what you have above seems to be the same as what SB select example does as far as that specific code.
w
Awesome.. thanks so much for your help Gary, really appreciate it!!
g
Hey @User if you are doing insert you need to be doing WITH CHECK not USING (as in the example for updates). That looks at new data.