Skip to content

v0.6.0

Choose a tag to compare

@SpaceShaman SpaceShaman released this 30 Jul 17:39
· 252 commits to master since this release

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 CASCADE to 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 _insert method to handle many-to-many fields.
  • Renamed _prepare_values_to_insert method to _prepare_data_to_insert for clarity and consistency.
  • Simplified the delete, insert, and update methods to use the table_name property 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_name method to handle intermediate tables.
  • Enhanced the save method to handle optional foreign keys with None values.
  • Added the _insert_many_to_many method to manage the insertion of related objects in many-to-many relationships.
  • Updated foreign key constraints to include ON UPDATE CASCADE for 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 DBModel instance.
  • 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_insert method 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_name method.
  • 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.md to 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
  • 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