Hi,
I use Sub-Document operations to patch documents in my couchbase 5.0.1.
Let’s consider that we want to update an existing document with following json:
{
"prop1": {
"": {
"prop2": "some value"
}
}
}
Please notice that there is a empty string as a key.
If I update document using path “prop1”:
asyncBucket.mutateIn(id).upsertDocument(true) //
.upsert("prop1", mapWithEmptyKey)
then it finishes successfully so the key with empty string is stored properly to database.
But if I try to use empty key in path then I receive error SUBDOC_PATH_INVALID. Examples of paths:
"prop1.``"
"prop1.``.prop2"
It is a bit inconsistent.
Is it possible to use Sub-Document api with “empty” keys? Is it a special notation for that case (other than putting value in double-backticks (``))?
vsr1
December 19, 2018, 6:38pm
2
Empty key is not valid JSON.
@vsr1
any update on that issue?
It seems it is possible to create JSON document using regular API, but sub-doc API is forbidding updating keys with empty String as key in path.
In case of usage sub-doc API
asyncBucket.mutateIn('documentId').upsertDocument(true) //
.upsert("prop1.``.anotherProperty", "someValue")
I’m receiving
Caused by: com.couchbase.client.java.error.subdoc.PathInvalidException: Path prop1.``.anotherProperty ends in an array index in documentId, expected dictionary
at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$4.call(AsyncMutateInBuilder.java:1399)
When creating document using
asyncBucket.upsert(jsonDocument)
I’m able to save values with empty keys
vsr1
May 20, 2021, 1:46pm
5
It might be limitation at present.
As far as N1QL is concern you can track via MB-46420