supabase/postgres-meta

Type generation: `unknown` generated for columns of views which are have the row type of a table

joeally opened this issue · 1 comments

Bug report

Describe the bug

In the situation where we have a view in which one of the columns has the row type of a table, unknown is generated for that column.

I've already created a fix for this in the PR #533

To Reproduce

Create a view in the following form that selects from an existing table of yours.

e.g

CREATE VIEW rows_with_user_view AS (
  SELECT *, users as user FROM rows
  INNER JOIN users on rows.user_id = user.id
);

Run type generation and search for rows_with_user_view

{
...typescript
  public: {
    ...
    Views: {
      rows_with_user_view: {
        Row: {
          ...
          user: unknown
        }
      }
    }
    ...
  }
...
}

Expected behavior

{
...
  public: {
    ...
    Views: {
      rows_with_user_view: {
        Row: {
          ...
          user: Database["public"]["Tables"]["users"]["Row"]
        }
      }
    }
    ...
  }
...
}

System information

  • OS: Mac OS 12.0.1 With supabase/postgres-meta running inside docker 20.10.11
  • Version of supabase/postgres-meta: Commit 27128d0

Is there any chance someone can look at my PR to fix this #533? It's a really short one which should only take a few minutes.