supabase / postgres-meta

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

fix(typegen): handle missing public schema #723

Closed sweatybridge closed 5 months ago

sweatybridge commented 5 months ago

What kind of change does this PR introduce?

supersedes https://github.com/supabase/postgres-meta/pull/717

What is the current behavior?

If public schema is not requested, the generated type fails to compile.

What is the new behavior?

When public schema is not requested, Tables<'name'> is now typed as unknown.

To use any non-public schema, pass in explicitly to Tables<{ schema: 'private' }, 'name'>.

Additional context

Add any other context or screenshots.

yingw787 commented 5 months ago

I just ran PG_META_GENERATE_TYPES_INCLUDED_SCHEMAS=openai PG_META_DB_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres npm run gen:types:typescript | xclip -sel clip and it works for me, so I'm happy with this!