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

Importing existing entity renames the original #314

Closed soininen closed 7 months ago

soininen commented 7 months ago

Reimporting an existing multidimensional entity updates the original item. Executing

import_data(db_map, entities=(("relationship_class", ("object1", "object2")),)

creates an entity object1__object2 as expected. However, executing the above statement again renames object1__object2 to object1__object2_1 which is unexpected.

Should the second import statement bail out without modifying the database mapping?

or

Should the second import statement add a new entity and keep the existing one?

manuelma commented 7 months ago

We can't add a new entity while keeping the existing one, it would violate the unique constraint on (class name, element name list). Option 1 is the way to go, will fix.