supabase icon indicating copy to clipboard operation
supabase copied to clipboard

Add support for database types on different schemas.

Open dts opened this issue 1 year ago • 4 comments

This plumbs through a config-set schema name to the types system.

Types of changes

  • [ ] Bug fix (a non-breaking change which fixes an issue)
  • [x] New feature (a non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Description

Currently, types do not correctly reflect overridden schemas. This PR allows that schema to be plumbed through reasonably.

Checklist:

  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have added tests to cover my changes (if not applicable, please state why) Not sure what tests apply here.

dts avatar Jul 18 '24 17:07 dts

Deploy request for n3-supabase pending review.

Visit the deploys page to approve it

Name Link
Latest commit b6e0beaab9dc80e90fbc1c76a73056c932aad848

netlify[bot] avatar Jul 18 '24 17:07 netlify[bot]

There's a problem with this at the moment as it seems that the types imports (here) in the composables are being wiped out when running the build command:

dist/runtime/composables/useSupabaseClient.d.ts

import type { SupabaseClient } from '@supabase/supabase-js';
export declare const useSupabaseClient: <T = unknown, S extends string & keyof T = Schema>() => SupabaseClient<T, S>;

https://github.com/nuxt-modules/supabase/issues/383#issuecomment-2236104268

For me this only works when running in the playground folder as the build is prepared using --stub, which doesn't remove any import.

If you want to reproduce just run pnpm run build and check dist/runtime/composables/useSupabaseClient.d.ts. You will see that import type { Database, Schema } from '#build/types/supabase-database' will be gone.

I am still figuring out how to fix this.

IsraelOrtuno avatar Jul 20 '24 15:07 IsraelOrtuno

@dts @IsraelOrtuno Could you have a check now that https://github.com/nuxt-modules/supabase/pull/404 has been merged?

larbish avatar Aug 29 '24 14:08 larbish

This fixed the issues with my PR so I would say it should work now @dts

IsraelOrtuno avatar Sep 20 '24 09:09 IsraelOrtuno