kristiandupont / kanel

Generate Typescript types from Postgres
https://kristiandupont.github.io/kanel/
MIT License
829 stars 57 forks source link

Optinal schema prefix to table name #556

Closed DROFEL closed 1 month ago

DROFEL commented 1 month ago

Addresses and closes #521

  1. Changed type union | to intersection & because with union kysely Database type breaks. So if for example Database type defined as type Database = PublicSchema | PrivateSchema; kysely instance will infer never as a table type QueryCreator<Database>.selectFrom<never>(from: never[]): SelectQueryBuilder<Database, never, {}> (+4 overloads), it breaks only autocomplition and doesnt influence actual functionality.
  2. Added optional schema prefix to a table name in schema interface to prevent possible collisions. Resulting in, assuming schema public has table example to be transfomed like this example => "public.example". Affects only schema interface.
  3. Added includeSchemaNameInTableName property that defaults to false and indicates if table names should be prefixed by schema name.

I'm not very experienced in contributing to open source so would appreciate any feedback :)

kristiandupont commented 1 month ago

Thank you for contributing! And don't worry about the CI failing, that is because I have broken main and still haven't fixed it. I did some work that should really have been on a branch.

kristiandupont commented 1 month ago

This is now published.