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): Fix support for custom SQL schemas in TypeScript type generation. #717

Closed yingw787 closed 5 months ago

yingw787 commented 5 months ago

What kind of change does this PR introduce?

[x] Patches PR #654 to support SQL schemas outside of "public". Cannot directly use keyword "schema" due to circular type constraint error in definition PublicTableNameOrOptions. [x] Update type generation tests to reflect updated TypeScript types, with local run of npm run test confirming 96 tests passed.

Addresses GitHub issue #716.

What is the current behavior?

When running:

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

Against a Supabase instance where database is at postgresql://postgres:postgres@127.0.0.1:54322/postgres and has schema openai among others, types Table, TablesInsert, TablesUpdate, and Enums result in type errors because schema public is not defined.

What is the new behavior?

Against a Supabase instance where database is at postgresql://postgres:postgres@127.0.0.1:54322/postgres and has schema openai among others, types Table, TablesInsert, TablesUpdate, and Enums do not result in type errors.

Additional context

N/A.

yingw787 commented 5 months ago

@sweatybridge mentioned in #723 I'm happy with those changes - I'll close this PR now. Thanks!