Skip to main content

validate_comment_references

Function validate_comment_references 

Source
pub(super) fn validate_comment_references(
    fqn: &FullyQualifiedName,
    comments: &[CommentStatement<Raw>],
    offsets: &[usize],
    main_ident: &DatabaseIdent,
    obj_type: &ObjectType,
    errors: &mut Vec<ValidationError>,
)
Expand description

Validates that all COMMENT statements in a file reference the main object.

Processes all COMMENT statements and ensures they target either:

  • The main object defined in the file, OR
  • A column of the main object

This validation ensures that each object file is self-contained and doesn’t reference other objects.

§Supported Comment Types

  • COMMENT ON TABLE - for tables and materialized views
  • COMMENT ON VIEW - for views
  • COMMENT ON MATERIALIZED VIEW - for materialized views
  • COMMENT ON SOURCE - for sources and subsources
  • COMMENT ON SINK - for sinks
  • COMMENT ON CONNECTION - for connections
  • COMMENT ON SECRET - for secrets
  • COMMENT ON COLUMN - for columns of the main object

§Errors

Returns an error if:

  • A comment references a different object
  • The comment type doesn’t match the object type
  • An unsupported comment type is used