supabase-js
supabase-js copied to clipboard
Unexpected type when querying referenced table with count
Bug report
Describe the bug
When querying a referenced table with count option like this:
const supabase = createClientComponentClient<Database>()
const { data } = supabase.from('concerts').select(`*, bands_count:j_concert_bands(count)`
count is returned correctly:
[
{
"id": 1,
"bands_count": [
{
"count": 29
}
]
}
]
But when using the returned count value there's a type error:
data.forEach(item => {
const count = item.bands_count[0].count
// Property 'count' does not exist on type 'SelectQueryError<"Referencing missing column `count`">'.
}
Expected behavior
No error message because count does in fact exist.
System information
- Version of supabase-js: 2.39.0
- Version of Node.js: 18.19.0
Im having same issue as well
This issue is active in the postgrest-js repo: https://github.com/supabase/postgrest-js/issues/447