Repository navigation
v0.6.0
The latest version introduces significant enhancements, new features, and refactorings focusing on many-to-many relationships, improved data integrity, and better code readability. Here are the main changes:
Code Refactoring
- Added foreign key constraints with
ON DELETE CASCADEto maintain referential integrity in database relations. - Extracted logic to check and create intermediate tables for many-to-many relationships into separate methods for better readability and
maintainability. - Optimized the
_insertmethod to handle many-to-many fields. - Renamed
_prepare_values_to_insertmethod to_prepare_data_to_insertfor clarity and consistency. - Simplified the
delete,insert, andupdatemethods to use thetable_nameproperty instead of class names. - Removed commented-out and unused methods to clean up code.
- Renamed and refactored methods for fetching and processing raw data for better organization and readability.
- Extracted logic for processing many-to-many data into separate methods.
New Features
- Added support for creating middleware tables for many-to-many relationships in the database.
- Introduced the
_get_intermediate_table_namemethod to handle intermediate tables. - Enhanced the
savemethod to handle optional foreign keys withNonevalues. - Added the
_insert_many_to_manymethod to manage the insertion of related objects in many-to-many relationships. - Updated foreign key constraints to include
ON UPDATE CASCADEfor better data integrity and consistency. - Added support for fetching all raw data and fetching one raw data with optional foreign key relationships.
- Added a method to update many-to-many intermediate tables when updating or inserting a
DBModelinstance. - Provided a property to get table names dynamically based on class names.
Tests
- Added tests for creating database tables with many-to-many relationships.
- Added tests for saving objects with many-to-many relationships.
- Added tests for the
_prepare_data_to_insertmethod to ensure correct data preparation for insertion. - Added tests for fetching raw data with and without foreign key relationships.
- Added tests for fetching raw data with many-to-many relationships.
- Added tests for the
_get_intermediate_table_namemethod. - Reorganized class definitions in test files to match the one-to-many and many-to-many relationships correctly.
Documentation
- Updated the task list in
README.mdto include different filter options and pagination support for filtering data and retrieving multiple records. - Added integration examples with FastAPI for the ORMagic library.
- Updated links to Pydantic and FastAPI for better readability and accessibility.
- Added documentation for defining many-to-many relationships in models.
In summary, this version significantly enhances the support for many-to-many relationships, improves data integrity, and ensures better code maintainability and readability.
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
- Unique constraints
- Remove table
- Filter data and retrieve multiple records
- Equal
- Not equal
- Greater than
- Greater than or equal
- Less than
- Less than or equal
- Contains
- Pagination
- Read all data from the database
- Update table schema
- Custom primary key
- Bulk operations (save, update, delete)
- Migrations
Full Changelog: v0.5.1...v0.6.0