fix/metal_archives #10

Merged
Elara6331 merged 15 commits from fix/metal_archives into experimental 2024-04-18 15:50:48 +00:00
2 changed files with 14 additions and 7 deletions
Showing only changes of commit f000ad4484 - Show all commits

View File

@ -60,8 +60,10 @@ class Collection(Generic[T]):
self._contains_ids.remove(__object.id)
for name, value in self._id_to_index_values[__object.id]:
del self._indexed_values[name]
del self._indexed_to_objects[value]
if name in self._indexed_values:
del self._indexed_values[name]
if value in self._indexed_to_objects:
del self._indexed_to_objects[value]
del self._id_to_index_values[__object.id]
@ -228,7 +230,6 @@ class Collection(Generic[T]):
else:
# merge only if the two objects are not the same
if existing_object.id == __object.id:
exit()
return
append_to._unmap_element(existing_object)
@ -282,7 +283,7 @@ class Collection(Generic[T]):
yield from c.__iter__(finished_ids=finished_ids)
def __merge__(self, __other: Collection, override: bool = False):
self.extend(__other.__iter__())
self.extend(__other)
def __getitem__(self, item: int):
if item < len(self._data):

View File

@ -194,17 +194,23 @@ class OuterProxy:
if a._inner is b._inner:
return
# switch instances if more efficient
if len(b._inner._refers_to_instances) > len(a._inner._refers_to_instances):
a, b = b, a
a._inner.__merge__(b._inner, override=override)
for collection, child_collection in b._inner._is_collection_child.items():
collection.children.remove(child_collection)
try:
collection.children.remove(child_collection)
except ValueError:
pass
for collection, parent_collection in b._inner._is_collection_parent.items():
collection.parents.remove(parent_collection)
try:
collection.parents.remove(parent_collection)
except ValueError:
pass
a._inner._refers_to_instances.update(b._inner._refers_to_instances)