Repository navigation
v0.3.0
The new version of the project includes numerous improvements and new features, mainly focused on supporting foreign key relationships between models, enhancing code organization, and increasing test coverage. Here are the main changes:
New Features
- Introduced support for
CASCADE,RESTRICT,SET DEFAULT,SET NULLandNO ACTIONon_delete actions for foreign key constraints.
Code Refactoring
- Refactored foreign key handling in the
DBModelclass for better readability and maintainability. - Simplified logic for handling foreign key models in the
_prepare_values_to_insertmethod. - Improved foreign key constraint generation logic for better readability and maintainability.
Tests
- Updated the
db_cursorfixture inconftest.pyto use theget_cursorfunction and properly close the connection. - Added test cases for deleting objects with foreign keys set to
CASCADE,RESTRICT,SET DEFAULT,SET NULLandNO ACTION
Fixes
- Updated the
execute_sqlfunction insql_utils.pyto use theget_cursorfunction, ensuring foreign key support is enabled.
Documentation
- Added documentation in
README.mdon how to define foreign keys with customon_deleteactions. - Provided examples in
README.mdon defining foreign keys with differenton_deleteoptions such asSET_NULL,RESTRICT,SET_DEFAULT,NO_ACTION, andCASCADE.
In summary, the new version brings advanced support for foreign key relationships, improved code organization, and comprehensive tests for key methods.
Features and Roadmap
- Define table schema using Pydantic models
- Basic CRUD operations
- Save data to the database
- Read data from the database
- Update data in the database
- Delete data from the database
- Relationships between tables
- One-to-many
- Create a tables with a foreign key
- Save data with a foreign key
- Read data with a foreign key
- Update data with a foreign key
- Delete data with a foreign key
- Cascade
- Set null
- Restrict
- Set default
- No action
- One-to-one
- Many-to-many
- One-to-many
- Custom primary key
- Bulk operations (save, update, delete)
- Migrations
Full Changelog: v0.2.1...v0.3.0