Fix PostgresAdapter support for ARRAY and custom enum array columns - #2423
Open
JulienChavee wants to merge 1 commit into
Open
Fix PostgresAdapter support for ARRAY and custom enum array columns#2423JulienChavee wants to merge 1 commit into
JulienChavee wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix PostgresAdapter support for ARRAY columns
Summary
PostgresAdapter::getColumns()throws when introspecting PostgreSQL array columns:PostgreSQL's
information_schema.columnsreports array columns asdata_type = 'ARRAY', with the element type inudt_name(e.g._int4,_text,_bpchar). Phinx already supported creating array columns (integer[],text[], …) but could not read them back.A related failure occurred for arrays of custom/user-defined types (e.g. enums):
isArrayType()previously required a known Phinx base type and only allowed[a-z]+, so identifiers with underscores were rejected.Changes
ARRAYcolumns ingetColumns()viaudt_nameandpg_attribute.attndimsisArrayType/getSqlTypegetSqlType(string[]→character varying[]); pass custom types through unchangedgetPhinxTypeused by arrayudt_namevalues:int2→smallintegerfloat8→doublebpchar→charparseArrayType(),getArraySqlType(), andgetPhinxArrayType()Example
_varchar_int4_my_status_enumAfter this change,
getColumns()maps those tostring[],integer[], andmy_status_enum[]respectively.Test plan
getColumns()round-trip for Phinx-created array types (text[],integer[], multi-dimensionaljson[][], …)varchar[],integer[][])custom_status_enum[]), includingchangeColumnround-tripudt_namealiases (_int2,_float8,_bpchar, …)getSqlType()translation of Phinx array base types (string[]→character varying[], etc.)PostgresAdapterTestsuite