Skip to content

Fix multi-word type name truncation in :: casts#10

Merged
gmr merged 1 commit into
mainfrom
fix/cast-multiword-type-truncation
Jun 15, 2026
Merged

Fix multi-word type name truncation in :: casts#10
gmr merged 1 commit into
mainfrom
fix/cast-multiword-type-truncation

Conversation

@gmr

@gmr gmr commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

'Free'::character varying formatted 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/Bit type nodes nest their keyword, VARYING qualifier, and length under wrapper nodes the single-pass type renderer never descended into:

  • CharacterWithLength > character > kw_character + opt_varying, length as a bare Iconst
  • BitWithLength > kw_bit + opt_varying, length as a parenthesized expr_list

Fix: flatten those wrapper nodes before rendering, and treat a bare Iconst or a parenthesized expr_list as the length modifier.

Verification

New regression test (cast_multiword_type_names) covers character varying, varchar(n), char(n), character varying(n), double precision, bit varying(n), and timestamp 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

`'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>
@gmr gmr merged commit 30a0b34 into main Jun 15, 2026
2 checks passed
@gmr gmr deleted the fix/cast-multiword-type-truncation branch June 15, 2026 17:37
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.

1 participant