supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
1.04k stars 133 forks source link

Computed relationships: Could not find a relationship #383

Closed putheng closed 1 year ago

putheng commented 1 year ago

Bug report

Computed relationships: Could not find a relationship

Describe the bug

Try to get computed relationships from foreigndb_fdw server by create a local table name loans that has order_id and create a function call orders

This is loans table image

orders function image

product_orders from foreigndb_fdw server image

To Reproduce

Call RESTApi url /rest/v1/loans?select=*,orders i got one-to-one relationship https://postgrest.org/en/stable/api.html#computed-cols image

Call RESTApi with url /rest/v1/loans?select=*,orders(*) https://postgrest.org/en/stable/api.html#computed-relationships image

Expected behavior

It should return setof relationship table https://postgrest.org/en/stable/api.html#computed-relationships

Additional context

Any way, I try to define the opposite one-to-many relationship image

than return multiple row instead of one-to-many image

steve-chavez commented 1 year ago

Could you share your postgREST version? It can be done as mentioned here.

Also try doing NOTIFY pgrst, 'reload schema';.

putheng commented 1 year ago

This is my version "info": { "description": "standard public schema", "title": "PostgREST API", "version": "9.0.1.20220717 (pre-release) (d2df289)" }

putheng commented 1 year ago

Solved by upgrading PostgREST to 10.1.1 (aaa4fbc)

kevinmlong commented 1 year ago

I'm using a self-hosted Supabase and I switched out the postgrest container to postgrest/postgrest:v10.1.1.20221215, but I'm still seeing an issue with queries using !inner returning an array of 1 instead of an object. For those that have successfully got this working, any thoughts?