The following dict is the result of a to_dict with pointers. The vectors of the to modules are equal and both should point to to the ref of the first occurence in _references. However, only the second one redirect to it, the first one stays {name : "Vector 1"} at location #/vessel/modules/0/origin or #/_references/1012d774-b552-11ee-8c66-4d72d9812f94/direction just like Module 2 whereas it should be
Insert these prints in the corresponding serialization.py method :
def add_references(dict_, memo, id_memo):
""" Add _references to a dict given the memos. """
dict_['_references'] = id_memo
# Rewriting dc__refs
for refpath, serialized, id_, object_path in memo.values():
name = serialized.get("name", "A")
print(f"{name}{' '*(10 - len(name))}: {id_} | {object_path}")
if not object_path.startswith('#/_references') and id_ in id_memo:
if REF_MARKER not in serialized:
print(f"{' '*14} Setting {REF_MARKER} : '#/_references/{id_}' @ {object_path}")
set_in_object_from_path(dict_, object_path, {REF_MARKER: f'#/_references/{id_}'})
for _, serialized, _, object_path in memo.values():
print(f"{object_path} => {get_in_object_from_path(dict_, object_path)}")
This shows how Vector 1 is at first well replaced in the resulting dict, but not in its parent dict. As his parent is replaced afterwards, this first operation is cancelled
What is the motivation / use case for changing the behavior?
The problem here is that we lose the information that these two vectors are initially equal to each other. When dealing with dicts only there is no way to get this information back
Possible fixes
We should probably inverse serialization order, but this seems dangerous, as the current issue occurs in a very specific usecase.
A refactor of how things are serialized, using OO, is probably a prerequisite
**Note: for support questions, please use https://nextcloud.dessia.tech/call/hr9z9bif
I'm submitting a ...
What is the current behavior?
The following dict is the result of a to_dict with pointers. The vectors of the to modules are equal and both should point to to the ref of the first occurence in
_references
. However, only the second one redirect to it, the first one stays{name : "Vector 1"}
at location#/vessel/modules/0/origin
or#/_references/1012d774-b552-11ee-8c66-4d72d9812f94/direction
just like Module 2 whereas it should beObject Structure
Script :
Insert these prints in the corresponding
serialization.py
method :This shows how Vector 1 is at first well replaced in the resulting dict, but not in its parent dict. As his parent is replaced afterwards, this first operation is cancelled
The problem here is that we lose the information that these two vectors are initially equal to each other. When dealing with dicts only there is no way to get this information back
We should probably inverse serialization order, but this seems dangerous, as the current issue occurs in a very specific usecase. A refactor of how things are serialized, using OO, is probably a prerequisite
Please tell us about your environment: