Details
Description
XDCR can not process JSON documents that are pure ARRAYs
Example I have two documents
ary1
|
[["a1","b2"],["a2","b2"]]
|
doc1
|
{ "b": 2 }
|
Now I add an object to the docs above (here I j used Eventing but I could have used any doc editor.
In eventing I do the following and deploy=/undeploy
function OnUpdate(doc, meta) {
|
if (Array.isArray(doc)) {
|
doc.push({"a":1});
|
} else {
|
doc.a = 1;
|
}
|
src_col[meta.id] = doc;
|
}
|
My two mutation document now look like
ary1
|
[["a1","b2"],["a2","b2"],{"a":1}]
|
doc1
|
{ "b": 2, "a": 1 }
|
Now in the XDCR filter expression I can deal with "doc1" the matches are nested to any depth so objects work fine.
Testing doc1 the three simple expressions like the following all work
a<1
|
a=1
|
a>1
|
Testing ary1 we see we have a serious problem I test
a=1
|
I get an error as follows:
Unable to process document body: json: cannot unmarshal array into Go value of type map[string]interface {}
But as noted the UI doc editor and Eventing have no issues with the two doc ary1
I can alsu use the query workbench ary1 is legal.
select * from A
|
will return
[
|
{
|
"A": [
|
[
|
"a1",
|
"b2"
|
],
|
[
|
"a2",
|
"b2"
|
],
|
{
|
"a": 1
|
}
|
]
|
},
|
{
|
"A": {
|
"a": 1,
|
"click": "to edit",
|
"comment": "xyz",
|
"with JSON": "there are no reserved field names"
|
}
|
}
|
]
|