Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cli-repl/test/e2e-bson.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('BSON e2e', function() {
MinKey: 'MinKey()',
MaxKey: 'MaxKey()',
NumberInt: 'Int32(32)',
NumberLong: 'Long("64")',
NumberLong: 'Long.fromString("64")',
Timestamp: 'Timestamp(1, 100)',
Symbol: 'abc',
Code: 'Code("abc")',
Expand Down Expand Up @@ -231,15 +231,15 @@ describe('BSON e2e', function() {
const value = 'NumberLong("64")';
await shell.writeInputLine(value);
await eventually(() => {
shell.assertContainsOutput('Long("64")');
shell.assertContainsOutput('Long.fromString("64")');
});
shell.assertNoErrors();
});
it('NumberLong prints when created by user (> MAX_SAFE_INTEGER)', async() => {
const value = 'NumberLong("345678654321234561")';
await shell.writeInputLine(value);
await eventually(() => {
shell.assertContainsOutput('Long("345678654321234561")');
shell.assertContainsOutput('Long.fromString("345678654321234561")');
});
shell.assertNoErrors();
});
Expand Down
6 changes: 5 additions & 1 deletion packages/service-provider-core/src/printable-bson.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ describe('BSON printers', function() {
});

it('formats NumberLong correctly', function() {
expect(inspect(bson.Long.fromString('64'))).to.equal('Long("64")');
expect(inspect(bson.Long.fromString('64'))).to.equal('Long.fromString("64")');
});

it('formats unsigned NumberLong correctly', function() {
expect(inspect(bson.Long.fromString('64', true))).to.equal('Long.fromString("64", true)');
});

it('formats NumberDecimal correctly', function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/service-provider-core/src/printable-bson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const bsonStringifiers: Record<string, (this: any) => string> = {
},

Long: function(): string {
return `Long("${this.toString()}")`;
return `Long.fromString("${this.toString()}"${this.unsigned ? ', true' : ''})`;
},

Binary: function(): string {
Expand Down