-
-
Notifications
You must be signed in to change notification settings - Fork 181
Description
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 }:
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.4Used Package Manager
yarn
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Supabase JS Library issue and not an issue with the Supabase platform. If it's a Supabase platform related bug, it should likely be reported to supabase/supabase instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.