gabledata / recap

Work with your web service, database, and streaming schemas in a single format.
https://recap.build
MIT License
334 stars 24 forks source link

Postgres converter support for enums #415

Closed mjperrone closed 10 months ago

mjperrone commented 10 months ago

It appears that the postgres -> recap converter currently does not support enums. It looks like there is no reference to enum in the postgres converter code. I also don't see any tests referencing enum in the postgres client integration tests.

I'm having some trouble getting my local recap dev env working, so I haven't tested this test, but I think this test in this PR should show the limitation:

https://github.com/recap-build/recap/pull/414

mjperrone commented 10 months ago

Looks like this should reveal the valid enum types:

SELECT unnest(enum_range(NULL::test_enum_type_mood));
 unnest 
--------
 sad
 ok
 happy
(3 rows)
criccomini commented 10 months ago

Ohh, this one's going to be tricky in the same way that PG array dimensions and types was tricky (#411).

It looks like we need to use udt_ stuff in the information_schema.columns view and also the pg_enum view to get the possible enum values.

EDIT: Gah, didn't see your second comment. Yea, that would be an alternative way to get the valid enum types.


Screenshot 2024-01-17 at 3 34 58 PM Screenshot 2024-01-17 at 3 35 11 PM

criccomini commented 10 months ago

I'm also curious how PG handles arrays of enums. I expect it to enforce valid values for the arrays, but given that it doesn't enforce dimensions, it's worth poking at this to make sure.