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

Fix array enum renaming #9067

Merged
merged 2 commits into from
Dec 13, 2024
Merged

Fix array enum renaming #9067

merged 2 commits into from
Dec 13, 2024

Conversation

charlesBochet
Copy link
Member

@charlesBochet charlesBochet commented Dec 13, 2024

When creating an enum type (let's say post_type_enum), postgres will automatically create a array enum type based on this enum and prefix it with an underscore (so _post_type_enum).

Our code was not taking this case into account while dealing with MULTISELECT

Resources:
https://www.postgresql.org/docs/current/sql-createtype.html

image

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR fixes PostgreSQL array enum type handling by properly managing the automatic '_' prefix that PostgreSQL adds to array enum types, particularly affecting MULTISELECT fields.

  • Added array type detection in getEnumTypeName by querying data_type from information_schema.columns
  • Modified enum type name extraction to remove '_' prefix when dealing with ARRAY data types in getEnumTypeName
  • Added specific error handling in getEnumTypeName when column is not found during enum alteration
  • Improved handling of array enum types in alterEnum to maintain consistency with PostgreSQL's naming convention

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@charlesBochet charlesBochet merged commit 2ceb1c8 into main Dec 13, 2024
19 checks passed
@charlesBochet charlesBochet deleted the fix-array-enum-rename branch December 13, 2024 18:16
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