© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
1 reply
LordZardeck

TS types incorrect for join tables

I have the following query:
const { data, error } = await supabaseClient
    .from('costs')
    .select('id, title, unit:unit_type_id(name), created_at, updated_at, price_per_unit')
    .eq('category_id', categoryId)
const { data, error } = await supabaseClient
    .from('costs')
    .select('id, title, unit:unit_type_id(name), created_at, updated_at, price_per_unit')
    .eq('category_id', categoryId)


Which results in the following type:
const data:
    | ({ id: string } & { title: string } & {
            unit: { name: unknown } | { name: unknown }[] | null
      } & { created_at: string } & { updated_at: string } & { price_per_unit: unknown })[]
    | null
const data:
    | ({ id: string } & { title: string } & {
            unit: { name: unknown } | { name: unknown }[] | null
      } & { created_at: string } & { updated_at: string } & { price_per_unit: unknown })[]
    | null


As you can see, the
unit
unit
join has incorrect property type of
unknown
unknown
, according to Supabase generated types, it should be
string | null
string | null
How can this be fixed?

On another, note,
unit
unit
shouldn't be able to be an array. Supabase apparently doesn't recognize the join table at all, and that might be the root of the issue
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Model Complex Join Tables
SupabaseSSupabase / help-and-questions
3y ago
TS Type for column returned by PostgREST is incorrect
SupabaseSSupabase / help-and-questions
3y ago
How to properly add types for nested tables in SvelteKit
SupabaseSSupabase / help-and-questions
4y ago
Supabase JS-RC8 Inner Join Types
SupabaseSSupabase / help-and-questions
4y ago