Skip to content

Conversation

@NFUChen
Copy link
Contributor

@NFUChen NFUChen commented Jul 20, 2025

Simplify Model Discovery and Improve Repository Implementation

Changes

Model Discovery

  • Removed model_file_postfix_patterns configuration and related file scanning logic
  • Simplified model class discovery to use Python's native __subclasses__() mechanism
  • Removed complex file path grouping and module importing logic
  • Eliminated potential issues with file path scanning and import errors

Repository Implementation

  • Converted CrudRepositoryImplementationService from a Component to a regular class
  • Added tracking of already implemented repository classes to prevent duplicate implementations
  • Improved error messages for missing required fields in queries
  • Added null-safety checks for query parameters

Provider Initialization

  • Restructured PySpringModelProvider initialization flow for better clarity
  • Separated model initialization and repository implementation into distinct methods
  • Moved table creation check to a more logical location in the initialization flow

Dependencies

  • Updated py-spring-core to version 0.0.22

Why

The previous model discovery mechanism relied on scanning file paths and matching patterns, which was:

  1. Error-prone due to file system dependencies
  2. Complex to configure and maintain
  3. Potentially slow due to file system operations

The new approach:

  1. Uses Python's built-in class relationship tracking
  2. Is more reliable and faster
  3. Requires zero configuration
  4. Works consistently across different environments

The repository implementation changes improve error handling and prevent potential issues with duplicate implementations.

Testing

All existing tests continue to pass. The changes are mostly architectural and don't affect the public API.

Migration

No migration steps are needed. The model_file_postfix_patterns configuration can be safely removed from any existing configuration files.

… and improve readability. Removed redundant engine setup code and ensured early return for skipped table creation.
…nd enhancing initialization logic for model classes and table creation.
…itions in CrudRepositoryImplementationService
…oryImplementationService to include keyword argument details
…pringModelProvider for enhanced CRUD operations
@NFUChen NFUChen changed the title Fix/create table mislocation Simplify Model Discovery and Improve Repository Implementation Jul 20, 2025
@NFUChen NFUChen merged commit d35a3db into main Jul 20, 2025
1 check passed
@NFUChen NFUChen deleted the fix/create-table-mislocation branch July 20, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants