Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postgres support for specifying schema when defining enum type #2638

Closed

Conversation

lazareviczoran
Copy link

Reopening #2183 after rebase

Hello!

Since we also ran into the need for specifying the schema name when defining a postgres enum to avoid collision when the enum types name appears in multiple schemas (#1171), here is an attempt to implement this feature.

This PR contains the following changes:

  • extending the enum type macro to accept a schema attribute
  • update postgres implementation to treat the enum types name as schema.enum_name when schema is specified
  • when querying the type info by type id from the pg_catalog, the schema's name + the count of type that have the same name as the type that is being queried are joined to the fetched data. In case there are multiple types with the same name, use the schema.enum_name format (unless the schema is the default public schema, in that case we just use the enum name)
  • when querying the type by name and if the schema attribute is provided, include it in the fetch query so that only the desired type gets returned.
  • add a test for an enum type defined with an already existing name color_upper but in a different schema test which verified that there is no collision with these 2 enums

This is a quite minimalistic implementation, therefore it's possible that some things are missing (some edge cases that need to be covered/tested, better code design, ...), if so, let me know and I'll be happy to add the requested changes.

@mymtw

This comment was marked as spam.

@abonander
Copy link
Collaborator

Superceded by #3252

@abonander abonander closed this Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants