Fix oplog converter case in which the value is an array but shouldnt be flattened

This commit is contained in:
Renan Castro
2022-01-06 20:55:35 -03:00
committed by Filipe Névola
parent eb82e917a7
commit d8fd0fb5ce
2 changed files with 8 additions and 2 deletions

View File

@@ -63,7 +63,7 @@ const nestedOplogEntryParsers = (
return {
...acc,
...(typeof setObjectSource[key] === 'object'
...(!Array.isArray(setObjectSource[key]) && typeof setObjectSource[key] === 'object'
? flattenObject({ [prefixedKey]: setObjectSource[key] })
: {
[prefixedKey]: setObjectSource[key],

View File

@@ -1,6 +1,6 @@
import { oplogV2V1Converter } from './oplog_v2_converter';
Tinytest.add('oplog - v2/v1 conversion', function(test) {
Tinytest.only('oplog - v2/v1 conversion', function(test) {
const entry1 = {
$v: 2,
diff: { scustom: { sEJSON$value: { u: { EJSONtail: 'd' } } } },
@@ -33,6 +33,8 @@ Tinytest.add('oplog - v2/v1 conversion', function(test) {
};
const entry8 = { $v: 2, diff: { u: { c: 'bar' }, sb: { a: true, u0: 2 } } };
const entry9 = {"$v":2,"diff":{"sservices":{"sresume":{"u":{"loginTokens":[]}}}}};
test.equal(
JSON.stringify(oplogV2V1Converter(entry1)),
JSON.stringify({
@@ -74,4 +76,8 @@ Tinytest.add('oplog - v2/v1 conversion', function(test) {
JSON.stringify(oplogV2V1Converter(entry8)),
JSON.stringify({ $v: 2, $set: { 'b.0': 2, c: 'bar' } })
);
test.equal(
JSON.stringify(oplogV2V1Converter(entry9)),
JSON.stringify({ '$v': 2, '$set': { 'services.resume.loginTokens': [] } })
);
});