PGRST200

Hi, I have a bigger problem with this error. I've already tried various ways to fix it with SQL. Different codes, re-adding, but nothing helps. I'm out of ideas, and I've been sitting here for days fighting with policies. ERROR Error fetching group members: {"code": "PGRST200", "details": "Searched for a foreign key relationship between 'expense_group_members' and 'user_id' in the schema 'public', but no matches were found.", "hint": null, "message": "Could not find a relationship between 'expense_group_members' and 'user_id' in the schema cache"} ERROR Error fetching expenses: {"code": "PGRST200", "details": "Searched for a foreign key relationship between 'group_expenses' and 'payer_id' in the schema 'public', but no matches were found.", "hint": null, "message": "Could not find a relationship between 'group_expenses' and 'payer_id' in the schema cache"} If anyone has any ideas and is able to advise/help, I would be extremely grateful. // Disabling RLS does not help either.
6 Replies
garyaustin
garyaustin2w ago
You would need to show your table details including the foreign keys. You don't mention what foreign keys you have setup at all.
Beazzy
BeazzyOP2w ago
Let me know if this comparison screenshot is sufficient.
No description
garyaustin
garyaustin2w ago
You don't have an fk between those two tables. You cannot use an fk thru auth.users with API calls if that is what you are relying on. It is better to have a profile table id (linked to auth.users) and all other tables link to the profile id column (which can be the user UUID).
Beazzy
BeazzyOP2w ago
Am I right in thinking that we should change fk from auth.user to profiles.id?
garyaustin
garyaustin2w ago
Yes if profile id is the auth.user UUID and optionally linked to auth.users. You may need to flush the postgREST cache with the change... NOTIFY pgrst, 'reload schema';
Beazzy
BeazzyOP2w ago
It is quite possible that I will have to delete the memory, because I may have already corrupted it a little. I will try it So far, the application logic works and does not throw any errors. I will just have to sit down with RLS to get everything sorted out, because that is the only thing holding me back. Thank you very much, auth.user was the problem :x I changed everything as it should be and there are no errors.

Did you find this page helpful?