Skip to content

Commit f160ded

Browse files
authored
fix(query-parser): use string for NumberLong stringify value COMPASS-7215 (#352)
1 parent 15b5f2a commit f160ded

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/query-parser/src/index.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,12 @@ e s`,
402402
context('when providing a long', function () {
403403
it('correctly converts to NumberLong', function () {
404404
const stringified = stringify({ test: bson.Long.fromNumber(5) });
405-
assert.equal(stringified, '{test: NumberLong(5)}');
405+
assert.equal(stringified, "{test: NumberLong('5')}");
406+
407+
assert.equal(
408+
stringify({ test: new bson.Long('123456789123456789') }),
409+
"{test: NumberLong('123456789123456789')}"
410+
);
406411
});
407412
});
408413

packages/query-parser/src/stringify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const BSON_TO_JS_STRING = {
8989
return `Timestamp({ t: ${v.high}, i: ${v.low} })`;
9090
},
9191
Long: function (v: Long) {
92-
return `NumberLong(${v.toString()})`;
92+
return `NumberLong('${v.toString()}')`;
9393
},
9494
Decimal128: function (v: Decimal128) {
9595
return `NumberDecimal('${v.toString()}')`;

0 commit comments

Comments
 (0)