Closed manuelma closed 1 year ago
Base: 74.49% // Head: 74.53% // Increases project coverage by +0.04%
:tada:
Coverage data is based on head (
2ef743f
) compared to base (2b45db6
). Patch coverage: 74.00% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Introduces a lazy, light-weight ORM.
This PR introduces a new class called DBCache (a subclass of the native python dict) for holding the contents of a DB in memory. DBCache maps table names to ids to CacheItem instances, where CacheItem is also a subclass of dict.
The DBCache can be populated incrementally by querying the different tables and processing the results by chunks.
CacheItem.__getitem__
is overriden to mimic a SQL JOIN, so for example users can access the field "class_name" for an object - which is not in the object table, but "class_id" is. So we use the class_id to find the object_class in the associated DBCache and then return its name. If the object_class is not yet in the cache, we advance the object_class query on demand until we find it. So it's as lazy as it gets.Checklist before merging