Skip to content

v0.61.1 introduces bug in typescript generation for computed column #568

Open
@ecchochan

Description

@ecchochan

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The below line introduced the bug in v0.61.1

pg_get_function_result(f.oid) as return_type,

- rt.typname as return_type,
+ pg_get_function_result(f.oid) as return_type,

The above results in computed column typehint always equal to unknown

To Reproduce

Setup Supabase with the following schema:

CREATE TABLE people (
  fname text,
  lname text
);

CREATE FUNCTION full_name(people) RETURNS text AS $$
  SELECT $1.fname || ' ' || $1.lname;
$$ LANGUAGE SQL;

Run

node \
  --no-warnings \
  dist/server/server.js \   
  gen types typescript \
  --include-schemas public

Or the following if docker-compose is setup with meta using v0.61.1:

docker-compose exec -T meta node \
  --no-warnings \
  dist/server/server.js \   
  gen types typescript \
  --include-schemas public

Expected behavior

The typescript generated should be

export interface Database {
  public: {
    Tables: {
      account: {
        Row: {
          fname: string | null;
          lname: string | null;
          full_name: string | null;
        };
      }
    }
...

Screenshots

The typescript generated is however

export interface Database {
  public: {
    Tables: {
      account: {
        Row: {
          fname: string | null;
          lname: string | null;
          full_name: unknown | null;
        };
      }
    }
...

System information

  • OS: macOS
  • Browser (if applies): N/A
  • Version of supabase-js: N/A
  • Version of Node.js: N/A

Additional context

Reverting the changes of the below resolve the issue

pg_get_function_result(f.oid) as return_type,

- rt.typname as return_type,
+ pg_get_function_result(f.oid) as return_type,

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions