Description
From a brief test, it seems that subsequent execute calls to the same MutateInBuilder cause all of the fields being mutated in the MutateIn to be set to null.
Example code:
var document = new Document<dynamic>
|
{
|
Id = "Test",
|
Content = new
|
{
|
name = "Couchbase"
|
}
|
};
|
|
bucket.Upsert(document);
|
var mutator = bucket.MutateIn<dynamic>("Test").Upsert("name", "Matt");
|
mutator.Execute();
|
Console.WriteLine(bucket.Get<dynamic>("Test"));
|
mutator.Execute();
|
Console.WriteLine(bucket.Get<dynamic>("Test"));
|
Expected Results:
{"id":"Test","cas":1562171798187409408,"token":"mt{bRef=, vbID= -1, vbUUID=-1, seqno=-1}","content":"{\"name\":\"Matt\"}"}
|
{"id":"Test","cas":1562171798210478080,"token":"mt{bRef=, vbID= -1, vbUUID=-1, seqno=-1}","content":"{\"name\":\"Matt\"}"}
|
Actual Results:
{"id":"Test","cas":1562171798187409408,"token":"mt{bRef=, vbID= -1, vbUUID=-1, seqno=-1}","content":"{\"name\":\"Matt\"}"}
|
{"id":"Test","cas":1562171798210478080,"token":"mt{bRef=, vbID= -1, vbUUID=-1, seqno=-1}","content":"{\"name\":null}"}
|
This behavior essentially amounts to dataloss when calling the same mutateIn object multiple times.
It should be possible to do this for error retry reasons, you can imagine that if you had a timeout you would want to check if the operation was successful and if not then run Execute() again, for example:
var result = mutator.Execute();
|
if (!result.Success) {
|
mutator.Execute();
|
}
|
For reference, in Java this works as expected.
Code:
JsonObject arthur = JsonObject.create()
|
.put("name", "Arthur")
|
.put("email", "kingarthur@couchbase.com")
|
.put("interests", JsonArray.from("Holy Grail", "African Swallows"));
|
|
bucket.upsert(JsonDocument.create("u:king_arthur", arthur));
|
MutateInBuilder build = bucket.mutateIn("u:king_arthur").upsert("name", "foo");
|
build.execute();
|
System.out.println(bucket.get("u:king_arthur"));
|
build.execute();
|
System.out.println(bucket.get("u:king_arthur"));
|
Results:
JsonDocument{id='u:king_arthur', cas=1562172075359141888, expiry=0, content={"name":"foo","interests":["Holy Grail","African Swallows"],"email":"kingarthur@couchbase.com"}, mutationToken=null}
|
JsonDocument{id='u:king_arthur', cas=1562172075371397120, expiry=0, content={"name":"foo","interests":["Holy Grail","African Swallows"],"email":"kingarthur@couchbase.com"}, mutationToken=null}
|
Attachments
For Gerrit Dashboard: NCBC-2017 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
111577,3 | NCBC-2017:Subsequent calls to MutateInBuilders cause fields to be set to null | release27 | couchbase-net-client | Status: MERGED | +2 | +1 |