shuvamk opened a new pull request, #2424:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2424

   `Expr::UnaryOp`'s `Display` writes `{op}{expr}` with no separator, so a 
nested unary operand is printed glued to the operator:
   
   ```sql
   SELECT ~ ~ 1
   ```
   
   prints as `SELECT ~~1`, which no longer reparses on any dialect (`Expected: 
an expression, found: ~~`). `SELECT - -1` prints as `SELECT --1` the same way; 
that one only breaks where `--` opens a line comment, so MySQL is unaffected.
   
   On PostgreSQL it changes meaning rather than failing, because `@@` is its 
own operator: `SELECT @ @ 1` (abs of abs) prints as `SELECT @@1`, which 
reparses as `UnaryOperator::DoubleAt` applied to `1`.
   
   The fix extends the existing "needs a space" condition so it also fires when 
the operand is another `Expr::UnaryOp`. Non-unary operands are unchanged, so 
`-1` and `NOT a` print as before.
   
   Tests are `parse_nested_unary_ops` in `tests/sqlparser_common.rs` and 
`parse_nested_pg_unary_ops` in `tests/sqlparser_postgres.rs`; I checked that 
both fail without the source change. The `AGENTS.md` pre-commit checks are 
clean locally.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to