SELECT after RPC function call does not JOIN new data #2933
Replies: 3 comments 6 replies
-
I tried it and got these results: SELECT * FROM upsert_posts(...) p
LEFT JOIN tags t ON p.id = t.pid; And when I include the |
Beta Was this translation helpful? Give feedback.
-
Interesting, but makes sense. I can't return the .select(`*, author(*), tags(name), hearts(count)${session ? ', bookmarks(count), liked:hearts(uid)' : ''}`, { count: 'exact' }) which gets a lot more complicated, and I'm still adding features. I need to return a For the moment I'm making two calls: an Ideas...
Trying to think outside the box. @steve-chavez J |
Beta Was this translation helpful? Give feedback.
-
You seem to consider "tags" as a part of "post" on your api level, i.e. you consider them "one thing" together. But you still want to normalize correctly on the data level. In cases like this, I do the following:
To make this performant, you need to take care to design the view in a way that parts of the query are not executed, when you don't request the related columns. So for example when you select from the view without the This also gives you the nice benefit of being able to just use plain POST / PUT / PATCH on this view for inserts, updates etc. - no need to write your own custom RPC, which is kind of unrelated to the actual endpoint. Everything will happen on |
Beta Was this translation helpful? Give feedback.
-
I have this function to upsert a post with the post's tags:
I call in Supabase like so:
The function works great, and the database gets the tags updated correctly. However, the
SELECT
option contains anEMPTY
array of tags. If I run a second call to the database with the select the exact same way, it will return the tags as expected.Is there any reason why the
select
after the rpc would not correctly grab the tabs, yet a another select call right after works correctly? Again, the data is in the database.J
Beta Was this translation helpful? Give feedback.
All reactions