PostgreSQL: COMMENT ON CONSTRAINT / OPERATOR / RULE#33
Merged
fmguerreiro merged 1 commit intomainfrom Apr 27, 2026
Merged
Conversation
Adds parser + AST coverage for the three remaining COMMENT ON shapes
that pgmold-sqlparser had been silently rejecting:
- `COMMENT ON CONSTRAINT name ON [DOMAIN] target IS '…'`
- `COMMENT ON OPERATOR name (left, right) IS '…'` (each side may be NONE)
- `COMMENT ON RULE name ON target IS '…'`
`Statement::Comment` gains two fields: `operator_args:
Option<CommentOperatorArgs>` (operand types for OPERATOR, modeled as
`Option<DataType>` per side so unary `NONE` is preserved), and
`on_domain: bool` (set when CONSTRAINT uses the `ON DOMAIN <domain>`
form). The existing `arguments` and `table_name` fields keep their
prior semantics for FUNCTION/PROCEDURE/AGGREGATE and TRIGGER/POLICY.
Refactors `parse_drop_operator_signature` to share the new
`parse_operator_arg_type_or_none` helper with `parse_comment`, since
both parse the `{ DataType | NONE }` slot shape.
Bumps fork to 0.63.0 and adds changelog/0.63.0.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 beNONEfor unary operatorsCOMMENT ON RULE name ON target IS '…'Changes
CommentObjectgainsConstraint,Operator,Rulevariants inkeyword_strandfrom_keyword.CommentOperatorArgs { left: Option<DataType>, right: Option<DataType> }carries the operand signature forOPERATOR, withDisplayrenderingNONEfor unary slots.Statement::Commentgains two fields:operator_args: Option<CommentOperatorArgs>andon_domain: bool(only meaningful forConstraint). Existing destructures will need to add the two fields.parse_commentdispatches the new variants:OPERATORusesparse_operator_name()(so+,myschema.@@, etc. round-trip) and a mandatory(slot, slot)signature.CONSTRAINTandRULErequire anON <relation>tail;CONSTRAINTadditionally acceptsON DOMAIN <domain>.parse_drop_operator_signatureto share a newparse_operator_arg_type_or_none()helper withparse_comment.0.63.0; addschangelog/0.63.0.md.Breaking changes
Statement::Commentaddsoperator_argsandon_domainfields. Consumers that destructure all fields explicitly must add them; those using..rest patterns are unaffected. Documented inchangelog/0.63.0.md.Test plan
cargo test --package pgmold-sqlparser(CI)tests/sqlparser_postgres.rs:parse_comment_on_constraint_on_table(binary form +IS NULL+IF EXISTS)parse_comment_on_constraint_on_domain(unqualified + schema-qualified domain)parse_comment_on_constraint_requires_relation_tail(error case)parse_comment_on_operator_binary(public.+(INTEGER, INTEGER))parse_comment_on_operator_prefix_left_none(unary prefix,NONEleft)parse_comment_on_operator_postfix_right_none(unary postfix,NONEright)parse_comment_on_operator_requires_argument_list(error case)parse_comment_on_rule+IS NULLparse_comment_on_rule_requires_relation_tail(error case)Statement::Commentdestructures intests/sqlparser_postgres.rsto include the two new fields.