Skip to content

Supabase improperly types postgrest computed relationships #1364

Open
@gwax

Description

@gwax

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Supabase supports making calls using postgrest computed relationships: https://postgrest.org/en/v12/references/api/resource_embedding.html#computed-relationships

However, these show up as typescript errors of the form SelectQueryError<"could not find the relation between ...">

The types for computed relationships (mostly) worked in 2.47.7 but broke starting in 2.47.8

To Reproduce

Minimal reproduction is available in the gwax/computed-relationships branch here: https://github.com/manapoolinc/supabase-playground/tree/gwax/computed-relationships

  1. Create a computed relationship: https://github.com/manapoolinc/supabase-playground/blob/gwax/computed-relationships/supabase/migrations/20250127194033_create_country_fns.sql#L1
  2. Use the computed relationship in a query: https://github.com/manapoolinc/supabase-playground/blob/gwax/computed-relationships/src/lib/db/countries.ts#L47
  3. See type error in IDE / typescript compiler: https://github.com/manapoolinc/supabase-playground/blob/gwax/computed-relationships/src/lib/db/countries.ts#L101

Expected behavior

No Type Errors in reproduction code

System information

  • Version of supabase: 2.6.8
  • Version of supabase-js: 2.48.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions