spine-tools / Spine-Database-API

Database interface to Spine generic data model
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
6 stars 5 forks source link

Purged items cannot be restored #325

Closed soininen closed 5 months ago

soininen commented 7 months ago

I would expect to be able to restore a purged item:

from spinedb_api import DatabaseMapping

with DatabaseMapping("sqlite://", create=True) as db_map:
    item, error = db_map.add_entity_class_item(name="my_class")
    assert not error
    db_map.purge_items("entity_class")
    item.restore()
    assert item.is_valid()

The above script, however, fails with assertion error from the last line, i.e. the item is, in fact, not valid.