fmguerreiro opened a new pull request, #2324:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2324
## Summary
Adds parser + AST coverage for the three remaining `COMMENT ON …` shapes
that the fork had been silently rejecting:
- `COMMENT ON CONSTRAINT name ON [DOMAIN] target IS '…'`
- `COMMENT ON OPERATOR name (left, right) IS '…'` — each side may be `NONE`
for unary operators
- `COMMENT ON RULE name ON target IS '…'`
## Changes
- `CommentObject` gains `Constraint`, `Operator`, `Rule` variants in
`keyword_str` and `from_keyword`.
- New `CommentOperatorArgs { left: Option<DataType>, right: Option<DataType>
}` carries the operand signature for `OPERATOR`, with `Display` rendering
`NONE` for unary slots.
- `Statement::Comment` gains two fields: `operator_args:
Option<CommentOperatorArgs>` and `on_domain: bool` (only meaningful for
`Constraint`). Existing destructures will need to add the two fields.
- `parse_comment` dispatches the new variants:
- `OPERATOR` uses `parse_operator_name()` (so `+`, `myschema.@@`, etc.
round-trip) and a mandatory `(slot, slot)` signature.
- `CONSTRAINT` and `RULE` require an `ON <relation>` tail; `CONSTRAINT`
additionally accepts `ON DOMAIN <domain>`.
- Refactors `parse_drop_operator_signature` to share a new
`parse_operator_arg_type_or_none()` helper with `parse_comment`.
- Bumps fork to `0.63.0`; adds `changelog/0.63.0.md`.
## Breaking changes
`Statement::Comment` adds `operator_args` and `on_domain` fields. Consumers
that destructure all fields explicitly must add them; those using `..` rest
patterns are unaffected. Documented in `changelog/0.63.0.md`.
## Test plan
- [ ] `cargo test --package pgmold-sqlparser` (CI)
- New tests in `tests/sqlparser_postgres.rs`:
- [x] `parse_comment_on_constraint_on_table` (binary form + `IS NULL` +
`IF EXISTS`)
- [x] `parse_comment_on_constraint_on_domain` (unqualified +
schema-qualified domain)
- [x] `parse_comment_on_constraint_requires_relation_tail` (error case)
- [x] `parse_comment_on_operator_binary` (`public.+(INTEGER, INTEGER)`)
- [x] `parse_comment_on_operator_prefix_left_none` (unary prefix, `NONE`
left)
- [x] `parse_comment_on_operator_postfix_right_none` (unary postfix,
`NONE` right)
- [x] `parse_comment_on_operator_requires_argument_list` (error case)
- [x] `parse_comment_on_rule` + `IS NULL`
- [x] `parse_comment_on_rule_requires_relation_tail` (error case)
- Updated all existing `Statement::Comment` destructures in
`tests/sqlparser_postgres.rs` to include the two new fields.
--
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]