den1k / subgraph

Reactive graph database for re-frame
Other
78 stars 2 forks source link

Post-order traversal variant for `add` #9

Closed julienfantin closed 5 years ago

julienfantin commented 7 years ago

This adds addl and addr and makes add an alias of addl.

add implemented a pre-order traversal which can be problematic for some use-cases. The details are captured in the test, but the short version is:

It can be impossible to update a recursive entity using addl if that entity is referenced further down in the tree through one of its joins. The traversal causes the update on the root to get merged over by one of the duplicates in the leaves.

Alternatives would be to drop down to the ref level and update the normalized data, or make sure to update all occurrences in the denormalized entity, which defeats our purpose.