BenSatori opened a new pull request, #3099: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/3099
```sql SELECT TRIM(LEADING FROM ' a ') FROM dual ``` currently fails in dialects without comma-separated `TRIM` (Oracle, MySQL, ANSI, MsSql, ...) with: ``` Expected: ), found: ' a ' ``` A trim direction followed directly by `FROM`, with the trim character omitted, is standard SQL and is accepted by Oracle, MySQL and PostgreSQL. `parse_trim_expr` already handles `<direction> FROM source` for dialects with `supports_comma_separated_trim()` (#2493). This PR also takes that path in every dialect when a direction was given. The trailing `, characters` list stays gated on `supports_comma_separated_trim()`. Bare `TRIM(FROM x)` is unchanged and is still rejected in the non-comma dialects. As with the existing `TRIM(FROM x)` and `TRIM(BOTH FROM x, 'c')` forms, `Expr::Trim` has no field for the `FROM`, so the statement is printed as `TRIM(LEADING ' a ')`. Keeping the `FROM` in the output would need a new `Expr::Trim` field. That is an AST change, so I left it out; I'm happy to follow up if you want it. References: [Oracle TRIM](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/TRIM.html), [MySQL TRIM](https://dev.mysql.com/doc/refman/8.4/en/string-functions.html#function_trim), [PostgreSQL string functions](https://www.postgresql.org/docs/current/functions-string.html) Fuzzed with `fuzz_parse_sql` and `fuzz_parse_roundtrip` for 60 seconds each, no panics. Seed: `fuzz/fuzz_seeds/oracle_trim_direction_without_characters.sql`. This PR was written with AI assistance (Claude Code). I reviewed every line and can explain each change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
