Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Aug 6, 2025

Summary

This PR enhances the validation logic for annotation option parameters (include/exclude) in DAO methods to properly handle embedded properties. The validation now provides better error messages and correctly validates nested property paths including embedded types.

Changes

Core Improvements

  1. Enhanced Validation for Embedded Properties

    • Added validation to detect when the last field in an option path is an @Embeddable type
    • Provides specific error messages suggesting which properties can be accessed from embeddable fields
    • Validates the entire property path chain for include/exclude options
  2. Improved Error Messaging

    • New validation result class ValidationAnnotationOptionEmbeddableResult for embeddable-specific errors
    • Clear suggestions showing available properties when validation fails
    • Better property path resolution for nested fields
  3. Extended Annotation Coverage

    • Validation now applies to @Update, @BatchUpdate, @Insert, @BatchInsert, and @MultiInsert annotations
    • Support for returning option validation with nested include/exclude properties

Technical Details

  • Modified Files:

    • DaoAnnotationOptionParameterCheckProcessor.kt - Core validation logic enhancements
    • DaoAnnotationOptionParameterInspectionVisitor.kt - Added support for Insert annotations
    • Various validation result classes for improved error reporting
  • Test Coverage:

    • Refactored test structure for better maintainability
    • Added test cases for embedded property validation scenarios
    • Verified validation works correctly with complex nested entity structures

Testing

All existing tests pass with the enhanced validation. The changes are backward compatible and don't affect existing functionality while providing better developer experience through improved error messages.

Related Issues

This change improves the developer experience when working with Doma's entity include/exclude options, particularly for projects using embedded properties extensively.

xterao and others added 6 commits July 29, 2025 17:51
…tions

- Implement DaoAnnotationOptionParameterInspection to validate include/exclude field names
- Add validation for @update and @BatchUpdate annotation options
- Check that field names in include/exclude options exist in the entity class
- Support nested field access validation with dot notation
- Add comprehensive test coverage for valid and invalid field references
- Include multilingual error messages in bundle files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@xterao xterao changed the title Add comprehensive annotation option parameter validation Enhance annotation option parameter validation for embedded properties Aug 6, 2025
@xterao xterao linked an issue Aug 6, 2025 that may be closed by this pull request
@xterao xterao merged commit 7efd750 into main Aug 7, 2025
5 checks passed
@xterao xterao deleted the feature/annotation-option-parameter-validation branch August 7, 2025 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Annotation Option Parameter Validation

2 participants