Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Conversation

mqp
Copy link
Contributor

@mqp mqp commented Jan 17, 2023

Previously, if you wrote a query like this:

// presumes a table foos that has a JSONB `data` column
const { data, error } = await client.from('foos').select('id').order('data->>count', { ascending: true })

It would fail to typecheck, because the typing for order thought that if the first parameter isn't a column name from the foos table in the schema, then it must be a foreign table reference, so the foreignTable property in the options must be specified.

Now, Typescript can extract the column name from the data->>count expression, and check that against the schema.

I think there are other expressions you can use here (the Postgrest docs mention computed columns) but this covers the JSON accessor case. (We could also probably use similar code in the filter builder to get better typechecking when using JSON accessors in a variety of methods.)

@mandarini
Copy link
Contributor

Hi @mqp ! Thanks for the contribution and your patience.

This repository is deprecated and has moved to the new Supabase JS monorepo. Since this PR has been inactive for over a year, I’m going to close it to keep the old repo tidy, before archiving.

If you believe this change is still needed, please open a new PR in the monorepo and include a link back to this thread for context:

Note: This old repository will be archived on October 10, 2025. Thank you again for your effort and understanding!

@mandarini mandarini closed this Oct 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants