Fix multi-word type name truncation in :: casts#10
Merged
Conversation
`'Free'::character varying` formatted to `'Free'::CHARACTER`, dropping the trailing words, and `::bit varying(8)` mis-rendered the length as the base type. The Character/Bit type nodes nest their keyword, VARYING qualifier, and length under wrapper nodes (CharacterWithLength > character > kw + opt_varying; BitWithLength > kw + ( expr_list )) that the single-pass type renderer never descended into. Flatten those wrappers before rendering, and treat a bare Iconst or a parenthesized expr_list as the length modifier. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
'Free'::character varyingformatted to'Free'::CHARACTER— the trailing words were dropped — and::bit varying(8)mis-rendered the length as the base type (::8 BIT VARYING).The
Character/Bittype nodes nest their keyword,VARYINGqualifier, and length under wrapper nodes the single-pass type renderer never descended into:CharacterWithLength > character > kw_character + opt_varying, length as a bareIconstBitWithLength > kw_bit + opt_varying, length as a parenthesizedexpr_listFix: flatten those wrapper nodes before rendering, and treat a bare
Iconstor a parenthesizedexpr_listas the length modifier.Verification
New regression test (
cast_multiword_type_names) coverscharacter varying,varchar(n),char(n),character varying(n),double precision,bit varying(n), andtimestamp with time zone. Full suite green.This was found while evaluating a
pg_dump/ruleutils format style (deparser output uses these casts heavily), but it's an independent correctness bug.🤖 Generated with Claude Code