fix: preserve length modifier in varchar(n)[] array columns (#420)#438
fix: preserve length modifier in varchar(n)[] array columns (#420)#438vytautas-karpavicius wants to merge 1 commit into
Conversation
Greptile SummaryThis PR preserves length modifiers for character array columns in schema dumps. The main changes are:
Confidence Score: 3/5This should be fixed before merging.
Important Files Changed
Reviews (1): Last reviewed commit: "fix: preserve length modifier in varchar..." | Re-trigger Greptile |
| WHEN en.nspname = 'pg_catalog' THEN et.typname | ||
| WHEN en.nspname = c.table_schema THEN et.typname | ||
| ELSE en.nspname || '.' || et.typname | ||
| END || COALESCE(substring(format_type(a.atttypid, a.atttypmod) FROM '\([^)]*\)'), '') || '[]' |
There was a problem hiding this comment.
Preserve interval fields When an array column uses an interval field range, such as
INTERVAL DAY TO SECOND(3)[], format_type(a.atttypid, a.atttypmod) includes both the fields and the precision. This substring only keeps the parenthesized precision, so the dumped type becomes interval(3)[] and drops DAY TO SECOND. That changes the column type semantics in the dump.
This PR fixes issue #420
varchar(128)[]was emitted asvarchar[])et.typname || '[]'for array types, which discards atttypmod. Non-array types already usedformat_type(a.atttypid, a.atttypmod)to extract the modifier — array types now do the samenormalizePostgreSQLTypeis updated to handle types-with-modifiers (e.g.bpchar(10)[]->character(10)[]) by decomposing the type name once and doing a single map lookup instead of twoTest plan
issue_420_varchar_array_length_modifiercovers varchar(128)[] and character(10)[] columnsgo test ./... -timeout 600s