Skip to content

Members of a list become disassociated when you mutate them #13

@nickretallack

Description

@nickretallack

Say you have a protocol buffer that contains a repeated element which in turn contains more repeated elements. If you mutate one of the repeated elements at the root, you're fine. However, if you mutate a repeated element that is a child of another repeated element, it becomes a different object from the one that's in its parent's list.

This demonstrates how the same object gets dissociated

nested_item = Top.items[0]
nested_item.items += (item,)
nested_item.items.length != Top.items[0].items.length

This quickly demonstrates the anomaly and how it eats data

length_before = Top.items[0].items.length
Top.items[0].items += (item,)
length_after = Top.items[0].items.length
length_before == length_after

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions