Open Tasqu opened 2 years ago
Well, it turns out that this is a pretty fundamental problem. The easiest way would be to simply prevent users from creating Objects
that already exist, e.g. by checking their database ids. Otherwise, we start running into issues about what the user tries to do with the Object
constructor. However, I'm not sure a change like this wouldn't mess something up.
E.g. how should the Object
constructor handle a situation where there already exists an object with a given name
, class_name
, members
, groups
, and id
, and the user uses the Object
constructor to create a new object with the exact same name
and class_name
, but different members
and groups
? Should SpineInterface
interpret this as an attempt to update the existing Object
, or an attempt to create a new Object
? And if the name
and object_class
are identical, how are the Objects
distinguished from one another?
Essentially, it seems that the
Object
constructor creates a duplicateObject
, that fools some of the code into thinking that theObject
is the same as one already in the database, while other functionality recognises that there's a difference. For example, when loading a database into memory with abuilding_archetype
ObjectClass
with anObject
calledIDA_ESBO_AB
:but
Furthermore, if comparing the fields of the
Object
s:and
where
I believe that
spinedb_api
doesn't allow duplicate objects inside the same object class, so we should probably fix theObject
constructor so that it either throws an error when trying to create a duplicate object, or refers to the pre-existing object instead.