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 #2183

Closed

Conversation

lazareviczoran
Copy link

@lazareviczoran lazareviczoran commented Oct 31, 2022

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.

@abonander
Copy link
Collaborator

@lazareviczoran sorry that it took so long to look at this, in the intervening time it looks like some merge conflicts were introduced.

I'm closing this due to inactivity, feel free to reopen if you want to address the conflicts.

@lazareviczoran
Copy link
Author

@lazareviczoran sorry that it took so long to look at this, in the intervening time it looks like some merge conflicts were introduced.

I'm closing this due to inactivity, feel free to reopen if you want to address the conflicts.

No worries, I rebased and opened #2638 instead.

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.

2 participants