Skip to content

Comments

fix: function type generation for zero arg and scalar computed fields#1035

Open
7ttp wants to merge 3 commits intosupabase:masterfrom
7ttp:fix/fn2
Open

fix: function type generation for zero arg and scalar computed fields#1035
7ttp wants to merge 3 commits intosupabase:masterfrom
7ttp:fix/fn2

Conversation

@7ttp
Copy link

@7ttp 7ttp commented Jan 31, 2026

Problems

  1. Zero arg functions cause columns with same name to be omitted from query types (never extends T is always true)
  2. Scalar computed fields like name_translated(products) are not added to Row types

Solution

  1. Use Record<PropertyKey, never> instead of never for zero-arg function Args
  2. Include functions with single unnamed table/view parameters in filtering logic

Related

Comment on lines +201 to +203
!getTableNameFromRelationId(func.return_type_relation_id, func.return_type_id)) ||
// OR if the function takes a table/view row (computed field)
tableAndViewNames.has(func.argument_types)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return fns
.map(({ fn, inArgs }) => {
let argsType = 'never'
let argsType = 'Record<PropertyKey, never>'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be tested with the inference within https://github.com/supabase/supabase-js/tree/master/packages/core/postgrest-js as I expect this might break a few things.

I remember having to use never specifically here to be able to detect the difference between actual functions with args, and functions with no args. Using a Record<string, never> in my memory didn't allowed that.

@prem-2006
Copy link

prem-2006 commented Feb 18, 2026

I am working on it, can you assign this issue to me.

Co-authored-by: Andrew Valleteau <avallete@users.noreply.github.com>
@prem-2006 prem-2006 mentioned this pull request Feb 18, 2026
prem-2006 added a commit to prem-2006/postgres-meta that referenced this pull request Feb 19, 2026
prem-2006 added a commit to prem-2006/postgres-meta that referenced this pull request Feb 19, 2026
prem-2006 added a commit to prem-2006/postgres-meta that referenced this pull request Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants