Comment 0 for bug 1210093

Revision history for this message
Ghislain Fourny (gislenius) wrote :

Because of snapshot semantics, in JSONiq it is perfectly fine to do things like:

variable $object := { "foo" : 1, "bar" : 2 };
(rename $object.foo as "bar", rename $object.bar as "foo");

However, Zorba does not support circular renames.

Even though updates are unordered, Zorba (like some other implementations) applies the update primitives in a special, precise order that guarantees that the result cannot be distinguished from the application of all updates at the same time against the same snapshot.

This works for most updates, but circular renames are an exception and need to be handled separately.

Possible strategy:
- Change the internal API of JSONObject::rename() to accept a vector of (old name, new name) pairs instead of just a single pair. This function then looks for the cycles in the vector and applies one rename cycle after the other, using, for each cycle, a temporary, unused name to roll-over.