fix(postgres): parse enums correctly when describing a table #12409
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
This bug affects v5 for sure, I haven't checked for v6 but I'm pretty sure it also applies to it.
When you have a PostgreSQL table containing a user-defined enum, if the last value of this enum contains multiple words, using a
describeTable()
on it will generate an array with a trailing quote due to a bad parsing of the result data. It works well in other cases (as long as the enum doesn't end with a multi-word value).Consider this schema:
Sequelize uses
array_agg(pg_catalog.pg_enum.enumlabel)
to fetch the enum values, before passing it toQueryGenerator.fromArray()
to parse it. In this case it will send the string{foo,bar,"foo bar"}
, and the resulting array will be['foo', 'bar', 'foo bar"']
, with the unwanted trailing quote.Tests aren't passing but I'm not sure that it's related to my fix, tell me if I need to change something! Here's the stacktrace just in case:
PS: I just re-created my PR to target master.