supabase/postgres-meta

CompositeTypes incorrectly handles unkown types.

BarnabyShearer opened this issue · 0 comments

Bug report

Describe the bug

We love the new CompositeTypes however if you have a property which is an unknown type it is output as unknown; rather then myfield: unknown;. I.e. it says the should be a property called "unknown" rater then typed as unknown.

To Reproduce

If you DB has something like:

CREATE TYPE public.example AS
(
    id text,
    foo text[]
);

And you generate types you get:

        CompositeTypes: {
            example: {
                id: string
                unknown
            };

Note I would also love a feature-request so that arrays preserve their type rather then being marked as unkown.

Expected behavior

A property with the correct name typed unknown; in-place of a property called "unknown" and implicitly typed any.

I believe the fix is to change line:

to return `${JSON.stringify(name)}: unknown`