supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.

Home Page:https://supabase.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Count on foreign table does not exist in type

dejorrit opened this issue · comments

  • 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

Selecting count from a foreign table returns Typescript error. This is my query:

const { data } = await supabase
      .from("projects")
      .select("*, cards(count)");

And this is the type of data:

const data: {
    created_at: string | null;
    id: string;
    name: string;
    owner_id: string | null;
    updated_at: string | null;
    cards: SelectQueryError<"Referencing missing column `count`">[];
}[] | null

And more specific:

Property 'count' does not exist on type 'SelectQueryError<"Referencing missing column `count`">'.

When selecting id instead of count on the foreign table everything works as expected.

To Reproduce

See above

Expected behavior

I expect count: number to be part of the generated type

Screenshots

image

I have the same problem.

"@supabase/auth-helpers-nextjs": "^0.8.1",
"@supabase/supabase-js": "^2.38.0",

Closing in favour of #447 and tracking there