FreeTakServer icon indicating copy to clipboard operation
FreeTakServer copied to clipboard

Persistency Implementation

Open naman108 opened this issue 2 years ago • 2 comments

Persistency requirements

  • Support Create operation to add a node instance to the DB
  • Support Delete operation to delete a node instance from the DB
  • Support Read operation to query nodes from the DB
  • Support Update operation to modify
  • Support the Creation of new tables as new classes are added
  • Support Modification of existing tables as classes are changed

Persistency risks

  • Interfere with existing applications of persistency
  • increase latency

Persistency milestones

  • [x] merge main into persistene
  • [x] Creation of tables as new classes are added
    • [x] check if the table exists every time the class is instantiated
    • [x] infer all table columns from the node attributes
    • [x] use sqlalchemy to instantiate new table
  • [ ] Create operation to add node instance to the DB
    • [x] check if table exists every time a node is instantiate
    • [x] access the object id at instantiation
    • [ ] instantiate a database persistent object with the object id
  • [ ] Read operation to access contents in the DB
    • [ ] add support for a static method in the persistency object which allows the passing of queries, in string form or as SQLAlchemy Queries *
    • [ ] instantiate node as return value without calling create or update operations
    • [ ] test all defined functionality
  • [ ] Update operation to modify node instance in the DB
    • [ ] override all attribute setters to make sqlalchemy call to update the change in the db
      • asynchronously should this update be performed asynchronously ignoring a failed state or should it be done synchronously raising an exception in the event it was not updated
      • should this be done on every update or should there be a manual update command used to send changes to the db?
    • [ ] add auto type checking to validate that the passed types are correct? (unpythonic, enforcing strict typing)
  • [ ] Modification of existing tables as classes are changed
    • [ ] check for differences between table columns and class attributes at class instantiation
    • [ ] if different, generate a table alter command (SQLAlchemy to my knowledge doesn't support altering tables in it's API
  • [ ] Delete operation to delete a node instance from the DB
    • [ ] when delete magic method is called check if an object with the given object_id exists in the DB
    • [ ] if it does delete the object using sqlalchemy

naman108 avatar Feb 08 '23 13:02 naman108

@naman108 how is that impacting the work we are doing with DigitalPi?

brothercorvo avatar Nov 28 '23 21:11 brothercorvo

it would change the way that we handle generation as we wouldn't need to generate an sqlalchemy table class but this will take a lot of work so probably out of scope for now.

naman108 avatar Nov 29 '23 12:11 naman108

@naman108 is this done with the new version of the DigitalPi

brothercorvo avatar Mar 18 '24 16:03 brothercorvo

no it's not been touched, currently we use an alternative system of builders, directors and controllers to perform the mapping

naman108 avatar Apr 21 '24 20:04 naman108