Skip to content

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

const tablesNamesByTableId: Record<number, string> = {}
const relationTypeByIds = new Map<number, (typeof types)[number]>()
// group types by id for quicker lookup
const typesById = new Map<number, (typeof types)[number]>()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const typesById = new Map<number, (typeof types)[number]>()
// group types by id for quicker lookup
const typesById = new Map<number, (typeof types)[number]>()

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants