Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Aug 17, 2022
1 parent a9c1b3f commit c6af1a8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class Binary {
if (!data) {
throw new BSONTypeError(`Unexpected Binary Extended JSON format ${JSON.stringify(doc)}`);
}
return type === 4 ? new UUID(data) : new Binary(data, type);
return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type);
}

/** @internal */
Expand Down
6 changes: 2 additions & 4 deletions src/parser/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,10 @@ function deserializeObject(

if (promoteBuffers && promoteValues) {
value = _buffer;
} else if (subType === constants.BSON_BINARY_SUBTYPE_UUID_NEW) {
value = new Binary(buffer.slice(index, index + binarySize), subType).toUUID();
} else {
value = new Binary(_buffer, subType);
value = new Binary(buffer.slice(index, index + binarySize), subType);
if (subType === constants.BSON_BINARY_SUBTYPE_UUID_NEW) {
value = value.toUUID();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/node/extended_json_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ Converting circular structure to EJSON:
const stringifiedUUID = EJSON.stringify({ uuid: exampleUUID });
const parsedUUID = EJSON.parse(stringifiedUUID);
const expectedResult = {
uuid: new UUID('878dac1201cc4830b271cbc8518e63ad')
uuid: new UUID('878dac12-01cc-4830-b271-cbc8518e63ad')
};
expect(parsedUUID).to.deep.equal(expectedResult);
});
Expand Down
2 changes: 1 addition & 1 deletion test/node/uuid_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('UUID', () => {
const serializedUUID = BSON.serialize({ uuid: exampleUUID });
const deserializedUUID = BSON.deserialize(serializedUUID);
const expectedResult = {
uuid: new UUID('878dac1201cc4830b271cbc8518e63ad')
uuid: new UUID('878dac12-01cc-4830-b271-cbc8518e63ad')
};
expect(deserializedUUID).to.deep.equal(expectedResult);
});
Expand Down

0 comments on commit c6af1a8

Please sign in to comment.