Skip to content

Commit cbb4724

Browse files
kvwalkerSophie Saskin
authored and
Sophie Saskin
committed
fix(serializer): do not use checkKeys for $clusterTime
Fixes NODE-1409
1 parent 5acdebf commit cbb4724

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: lib/parser/serializer.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const constants = require('../constants');
1010
const normalizedFunctionString = require('./utils').normalizedFunctionString;
1111

1212
const regexp = /\x00/; // eslint-disable-line no-control-regex
13+
const ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']);
1314

1415
// To ensure that 0.4 of node works correctly
1516
const isDate = function isDate(d) {
@@ -785,7 +786,7 @@ function serializeInto(
785786
const type = typeof value;
786787

787788
// Check the key and throw error if it's illegal
788-
if (key !== '$db' && key !== '$ref' && key !== '$id') {
789+
if (!ignoreKeys.has(key)) {
789790
if (key.match(regexp) != null) {
790791
// The BSON spec doesn't allow keys with null bytes because keys are
791792
// null-terminated.
@@ -885,7 +886,7 @@ function serializeInto(
885886
const type = typeof value;
886887

887888
// Check the key and throw error if it's illegal
888-
if (key !== '$db' && key !== '$ref' && key !== '$id') {
889+
if (!ignoreKeys.has(key)) {
889890
if (key.match(regexp) != null) {
890891
// The BSON spec doesn't allow keys with null bytes because keys are
891892
// null-terminated.

0 commit comments

Comments
 (0)