© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
6 replies
trunch

TS Type for column returned by PostgREST is incorrect

I've got a select query which is returning a column which is self-referential and it's working however the column being returned is typed as an array of the object rather than the actual object being returned. Anyone know how to fix this?

Eg.
const { data, error } = await supabase
.from('builds')
.select(
    `
    *,
    revision: revision_of_build_id ( * )
  `
)
.eq('id', id)
.single()
const { data, error } = await supabase
.from('builds')
.select(
    `
    *,
    revision: revision_of_build_id ( * )
  `
)
.eq('id', id)
.single()


In this example,
revision_of_build_id
revision_of_build_id
is referencing
builds.id
builds.id
. The actual
data
data
coming back correctly has all
build
build
columns on the row + a
revision
revision
key which correctly shows a single
build
build
row. The problem is that the TS type for
data
data
thinks that the value of the
revision
revision
key is an array of
builds
builds
rather than a single row object. I would be fine with
revision
revision
actually returning an
array
array
of 1 to match the type, the tough part is that it's returning an
object
object
.

Any ideas?
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

TS types incorrect for join tables
SupabaseSSupabase / help-and-questions
4y ago
JSON column is being returned as a string?
SupabaseSSupabase / help-and-questions
4y ago
supabase v2 - type returned is undefined[] | undefined
SupabaseSSupabase / help-and-questions
4y ago
PostgREST
SupabaseSSupabase / help-and-questions
6mo ago