Skip to content

[2.1.0] Rewrite .to_s/.to_i/.to_f only as whole words - #22

Open
OffgridwithJD wants to merge 1 commit into
commandprompt:masterfrom
OffgridwithJD:fix/to-cast-word-boundary
Open

OffgridwithJD wants to merge 1 commit into
commandprompt:masterfrom
OffgridwithJD:fix/to-cast-word-boundary

Conversation

@OffgridwithJD

Copy link
Copy Markdown

Summary

The shared expression rewriter turned .to_ followed by i, s or f into a cast wherever it appeared, so a field whose name starts with one of them broke:

Source Generated before Generated now
r.to_status r::texttatus (type "texttatus" does not exist) r.to_status
r.to_s_name r::text_name r.to_s_name
n.to_s() n::text() (syntax error) n::text

The rewrite now applies only when the suffix ends the word. An empty argument list after it is dropped along with the method name. This affected every dialect that uses the shared rewriter. The .to_s, .to_i and .to_f forms themselves are unchanged.

The plxcsharp front end's review found this.

Testing

  • make installcheck: all 13 suites pass on PG 18.4. CI covers 13 to 18.
  • make differentialcheck: 0 unexplained.
  • A new plx_features case reads to_status, to_s_name and to_items fields alongside n.to_s, n.to_s(), '4.5'.to_f and '12'.to_i + 1.

Code-only, so no ALTER EXTENSION is needed.

🤖 Generated with Claude Code

The shared rewriter turned '.to_' plus i, s or f into a cast wherever it
appeared, so a field named to_status became r::texttatus (and to_s_name
r::text_name). The suffix must now end the word. 'x.to_s()' drops the empty
argument list with the method name instead of leaving '::text()'.

Reported by the plxcsharp front end's review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants