supabase / postgres-meta

A RESTful API for managing your Postgres. Fetch tables, add roles, and run queries
https://supabase.com
Apache License 2.0
941 stars 126 forks source link

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

Open joeally opened 1 year ago

joeally commented 1 year ago

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

joeally commented 1 year ago

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.