Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/jsoniq-multiple-updates-fix into lp:zorba.
Requested reviews: Matthias Brantner (matthias-brantner) Markos Zaharioudakis (markos-za) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/jsoniq-multiple-updates-fix/+merge/114183 Fix that gives precedence to an array replacement over an array deletion, and tests about multiple updates with same selector on arrays and on objects. -- https://code.launchpad.net/~zorba-coders/zorba/jsoniq-multiple-updates-fix/+merge/114183 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/store/naive/simple_pul.cpp' --- src/store/naive/simple_pul.cpp 2012-07-04 12:56:09 +0000 +++ src/store/naive/simple_pul.cpp 2012-07-10 13:06:20 +0000 @@ -1531,7 +1531,8 @@ for (; ite != end; ++ite) { - if ((*ite)->getKind() != store::UpdateConsts::UP_JSON_ARRAY_DELETE) + if ((*ite)->getKind() != store::UpdateConsts::UP_JSON_ARRAY_DELETE && + (*ite)->getKind() != store::UpdateConsts::UP_JSON_ARRAY_REPLACE_VALUE) continue; UpdJSONArrayUpdate* upd = static_cast<UpdJSONArrayUpdate*>(*ite); @@ -1611,7 +1612,7 @@ if (upd->thePosition == pos) { - return; + ite = updates->erase(ite); } } } @@ -2094,7 +2095,8 @@ for (; ite != end; ++ite) { - if ((*ite)->getKind() != otherUpdKind) + if ((*ite)->getKind() != store::UpdateConsts::UP_JSON_ARRAY_DELETE && + (*ite)->getKind() != store::UpdateConsts::UP_JSON_ARRAY_REPLACE_VALUE) continue; UpdJSONArrayUpdate* myUpd = static_cast<UpdJSONArrayUpdate*>(*ite); @@ -2133,8 +2135,7 @@ { if (myUpd->thePosition == otherUpd2->thePosition) { - merged = true; - break; + ite = targetUpdates->erase(ite); } } } === added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/arr_update_01.xml.res' --- test/rbkt/ExpQueryResults/zorba/jsoniq/arr_update_01.xml.res 1970-01-01 00:00:00 +0000 +++ test/rbkt/ExpQueryResults/zorba/jsoniq/arr_update_01.xml.res 2012-07-10 13:06:20 +0000 @@ -0,0 +1,1 @@ +[ 1, 5, 6, 4, 3 ] \ No newline at end of file === added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/obj_update_01.xml.res' --- test/rbkt/ExpQueryResults/zorba/jsoniq/obj_update_01.xml.res 1970-01-01 00:00:00 +0000 +++ test/rbkt/ExpQueryResults/zorba/jsoniq/obj_update_01.xml.res 2012-07-10 13:06:20 +0000 @@ -0,0 +1,1 @@ +{ "foo2" : "bar2", "bar" : "foo" } === added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/obj_update_02.xml.res' --- test/rbkt/ExpQueryResults/zorba/jsoniq/obj_update_02.xml.res 1970-01-01 00:00:00 +0000 +++ test/rbkt/ExpQueryResults/zorba/jsoniq/obj_update_02.xml.res 2012-07-10 13:06:20 +0000 @@ -0,0 +1,1 @@ +{ "bar" : "foo" } === added file 'test/rbkt/Queries/zorba/jsoniq/arr_update_01.xq' --- test/rbkt/Queries/zorba/jsoniq/arr_update_01.xq 1970-01-01 00:00:00 +0000 +++ test/rbkt/Queries/zorba/jsoniq/arr_update_01.xq 2012-07-10 13:06:20 +0000 @@ -0,0 +1,12 @@ +import module namespace j = "http://www.jsoniq.org/functions"; + +variable $a := [ 1, 2, 3]; + +( + replace json value of $a(2) with 4, + insert json (5, 6) into $a at position 2, + delete json $a(2), + delete json $a(2) +); + +$a === added file 'test/rbkt/Queries/zorba/jsoniq/arr_update_02.spec' --- test/rbkt/Queries/zorba/jsoniq/arr_update_02.spec 1970-01-01 00:00:00 +0000 +++ test/rbkt/Queries/zorba/jsoniq/arr_update_02.spec 2012-07-10 13:06:20 +0000 @@ -0,0 +1,1 @@ +Error: http://www.jsoniq.org/errors:JNUP0009 \ No newline at end of file === added file 'test/rbkt/Queries/zorba/jsoniq/arr_update_02.xq' --- test/rbkt/Queries/zorba/jsoniq/arr_update_02.xq 1970-01-01 00:00:00 +0000 +++ test/rbkt/Queries/zorba/jsoniq/arr_update_02.xq 2012-07-10 13:06:20 +0000 @@ -0,0 +1,13 @@ +import module namespace j = "http://www.jsoniq.org/functions"; + +variable $a := [ 1, 2, 3]; + +( + replace json value of $a(2) with 4, + replace json value of $a(2) with 4, + insert json (5, 6) into $a at position 2, + delete json $a(2), + delete json $a(2) +); + +$a === added file 'test/rbkt/Queries/zorba/jsoniq/obj_update_01.xq' --- test/rbkt/Queries/zorba/jsoniq/obj_update_01.xq 1970-01-01 00:00:00 +0000 +++ test/rbkt/Queries/zorba/jsoniq/obj_update_01.xq 2012-07-10 13:06:20 +0000 @@ -0,0 +1,11 @@ +import module namespace j = "http://www.jsoniq.org/functions"; + +variable $o := { "foo" : "bar" }; + +( + replace json value of $o("foo") with "bar2", + rename json $o("foo") as "foo2", + insert json { "bar" : "foo" } into $o +); + +$o === added file 'test/rbkt/Queries/zorba/jsoniq/obj_update_02.xq' --- test/rbkt/Queries/zorba/jsoniq/obj_update_02.xq 1970-01-01 00:00:00 +0000 +++ test/rbkt/Queries/zorba/jsoniq/obj_update_02.xq 2012-07-10 13:06:20 +0000 @@ -0,0 +1,12 @@ +import module namespace j = "http://www.jsoniq.org/functions"; + +variable $o := { "foo" : "bar" }; + +( + replace json value of $o("foo") with "bar2", + rename json $o("foo") as "foo2", + insert json { "bar" : "foo" } into $o, + delete json $o("foo") +); + +$o
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp