supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.

Home Page:https://supabase.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Computed relationships: Could not find a relationship

putheng opened this issue · comments

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

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

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

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

Solved by upgrading PostgREST to 10.1.1 (aaa4fbc)

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?