Skip to content

Allow any expression as the value of CAST - #304

Merged
git-hulk merged 2 commits into
AfterShip:masterfrom
vincentbernat:fix/cast-expr-operand
Aug 5, 2026
Merged

Allow any expression as the value of CAST#304
git-hulk merged 2 commits into
AfterShip:masterfrom
vincentbernat:fix/cast-expr-operand

Conversation

@vincentbernat

Copy link
Copy Markdown
Contributor

CAST read its value with the primary expression parser, so an operator
stopped it: CAST(a + 1 AS String) and CAST(a + 1, 'String') both failed
at the plus sign. Parse the value at the lowest precedence instead,
which also accepts a leading minus as in CAST(-1 AS Int8).

There is a second (unrelated) commit to fix a crash that I discovered at the same time while debugging this issue.

CAST read its value with the primary expression parser, so an operator
stopped it: CAST(a + 1 AS String) and CAST(a + 1, 'String') both failed
at the plus sign. Parse the value at the lowest precedence instead,
which also accepts a leading minus as in CAST(-1 AS Int8).
The end position of the column was read from the expression before the
error was checked, so any parse failure in DEFAULT, MATERIALIZED or
ALIAS dereferenced a nil expression.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@git-hulk git-hulk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@git-hulk
git-hulk merged commit e5ab996 into AfterShip:master Aug 5, 2026
1 check passed
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