Describe the bug
When a postgres function with no arguments has the same name as a column in a table, those columns are omitted from the return type of .select('*') queries.
This seems to be related to ComputedField types in postgrest-js/src/select-query-parser/utils.ts. The ComputedField type checks whether a function's Args extends { '': Row }:
https://github.com/supabase/supabase-js/blob/7ec2df9f02e13fb00cf3d1491f140224f0e35546/packages/core/postgrest-js/src/select-query-parser/utils.ts#L654-L665
When Args is never, this check passes because never extends T is true for all T. The function is then treated as a computed field, and the column is removed from the * result (via Omit<Row, GetComputedFields<...>>)
This was not an issue is supabase cli v1.x, which generated Args: Record<PropertyKey, never> for functions with no args, but broke when it was changed to Args: never in 2.x
Library affected
postgrest-js
Reproduction
No response
Steps to reproduce
In this example, there's a songs table with a column secret, and separately a function secret:
CREATE TABLE songs (
id uuid PRIMARY KEY,
name text NOT NULL,
secret text
);
-- Zero-argument function with same name as column
CREATE FUNCTION secret() RETURNS text AS $$
SELECT current_setting('request.headers')::json->>'x-secret';
$$ LANGUAGE sql;
Running supabase gen types typescript (CLI v2.x) generates:
// In Tables
songs: {
Row: {
id: string
name: string
secret: string | null
}
}
// In Functions
secret: { Args: never; Returns: string }
Then querying:
const { data } = await supabase.from('songs').select('*').single();
// Expected: data.secret is accessible
// Actual: `secret` is missing from the inferred type of `data`
System Info
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M1 Max
Memory: 158.11 MB / 32.00 GB
Shell: 5.9 - /opt/homebrew/bin/zsh
Binaries:
Node: 22.14.0 - /Users/david.barrell/.local/share/mise/installs/node/22.14.0/bin/node
Yarn: 4.10.3 - /Users/david.barrell/.local/share/mise/installs/node/22.14.0/bin/yarn
npm: 10.9.2 - /Users/david.barrell/.local/share/mise/installs/node/22.14.0/bin/npm
bun: 1.2.4 - /Users/david.barrell/.local/share/mise/installs/bun/1.2.4/bin/bun
Deno: 2.1.4 - /Users/david.barrell/.deno/bin/deno
Browsers:
Chrome: 143.0.7499.170
Firefox: 141.0
Safari: 18.5
npmPackages:
@supabase/ssr: ^0.8.0 => 0.8.0
@supabase/supabase-js: ^2.93.3 => 2.93.3
supabase: ^2.74.4 => 2.74.4
Used Package Manager
yarn
Logs
No response
Validations
Describe the bug
When a postgres function with no arguments has the same name as a column in a table, those columns are omitted from the return type of
.select('*')queries.This seems to be related to
ComputedFieldtypes inpostgrest-js/src/select-query-parser/utils.ts. TheComputedFieldtype checks whether a function'sArgsextends{ '': Row }:https://github.com/supabase/supabase-js/blob/7ec2df9f02e13fb00cf3d1491f140224f0e35546/packages/core/postgrest-js/src/select-query-parser/utils.ts#L654-L665
When
Argsisnever, this check passes becausenever extends Tistruefor allT. The function is then treated as a computed field, and the column is removed from the*result (viaOmit<Row, GetComputedFields<...>>)This was not an issue is supabase cli v1.x, which generated
Args: Record<PropertyKey, never>for functions with no args, but broke when it was changed toArgs: neverin 2.xLibrary affected
postgrest-js
Reproduction
No response
Steps to reproduce
In this example, there's a
songstable with a columnsecret, and separately a functionsecret:Running
supabase gen types typescript(CLI v2.x) generates:Then querying:
System Info
System: OS: macOS 15.5 CPU: (10) arm64 Apple M1 Max Memory: 158.11 MB / 32.00 GB Shell: 5.9 - /opt/homebrew/bin/zsh Binaries: Node: 22.14.0 - /Users/david.barrell/.local/share/mise/installs/node/22.14.0/bin/node Yarn: 4.10.3 - /Users/david.barrell/.local/share/mise/installs/node/22.14.0/bin/yarn npm: 10.9.2 - /Users/david.barrell/.local/share/mise/installs/node/22.14.0/bin/npm bun: 1.2.4 - /Users/david.barrell/.local/share/mise/installs/bun/1.2.4/bin/bun Deno: 2.1.4 - /Users/david.barrell/.deno/bin/deno Browsers: Chrome: 143.0.7499.170 Firefox: 141.0 Safari: 18.5 npmPackages: @supabase/ssr: ^0.8.0 => 0.8.0 @supabase/supabase-js: ^2.93.3 => 2.93.3 supabase: ^2.74.4 => 2.74.4Used Package Manager
yarn
Logs
No response
Validations