Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrongly format the string in UnaryExpr #123

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

git-hulk
Copy link
Member

This closes #122

@git-hulk git-hulk requested review from Copilot and Lance726 February 28, 2025 02:38
@git-hulk git-hulk changed the title Fix wrongly string format in UnaryExpr Fix wrongly format the string in UnaryExpr Feb 28, 2025

Choose a reason for hiding this comment

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

PR Overview

This PR addresses the formatting of unary expressions in the AST by updating the string representation of a UnaryExpr and adjusting its parsing logic.

  • Update UnaryExpr.String() to compose the operator and operand using the token’s string representation.
  • Refactor parseUnaryExpr in parser_column.go to rename a local variable and update the conversion for setting the operator in a UnaryExpr.

Reviewed Changes

File Description
parser/ast.go Updated the String method for UnaryExpr to use token-based formatting.
parser/parser_column.go Updated variable naming and conversion for operator determination in unary expressions.

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

parser/ast.go:6648

  • Confirm that inserting a space between the operator and operand is desired in all cases, as it may alter the formatting for certain unary operators.
return string(n.Kind) + " " + n.Expr.String()

parser/parser_column.go:319

  • Verify that converting op.ToString() to TokenKind reliably produces the correct token type for unary expressions, as discrepancies may occur if the string representation differs from expected token values.
Kind:     TokenKind(op.ToString()),
Copy link
Collaborator

@Lance726 Lance726 left a comment

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 5dc6713 into AfterShip:master Feb 28, 2025
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.

Bug in Query Parser - Incorrect Translation of NOT isZeroOrNull(x)
2 participants