Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NODE-4877): Add support for useBigInt64 #3519

Merged
merged 33 commits into from
Feb 23, 2023
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d54383d
feat(NODE-4950)!: remove bson-ext import and squash commits
nbbeeken Jan 13, 2023
6eea5be
Merge branch 'main' into NODE-4877/add-support-for-BSON-useBigInt64-flag
W-A-James Feb 8, 2023
9f623a7
ci(NODE-4877): Fix generate_evergreen_tasks.js
W-A-James Feb 8, 2023
ddda8f8
test(NODE-4877): Work on resolving review comments
W-A-James Feb 15, 2023
6ac4651
test(NODE-4877): Change test name
W-A-James Feb 15, 2023
330a27a
test(NODE-4877): Add new test
W-A-James Feb 15, 2023
90a5cea
test(NODE-4877): add new tests
W-A-James Feb 16, 2023
2e40c2b
test(NODE-4877): Update tests
W-A-James Feb 17, 2023
cde8f0a
fix(NODE-4877): Add validation for bson options
W-A-James Feb 17, 2023
bbf39e8
fix(NODE-4877): revert unneeded change
W-A-James Feb 17, 2023
6b7ed65
fix(NODE-4877): Revert unneeded change
W-A-James Feb 17, 2023
6ca31e8
style(NODE-4877): eslint
W-A-James Feb 17, 2023
ddcc45b
Merge branch 'main' into NODE-4877/add-support-for-BSON-useBigInt64-flag
W-A-James Feb 17, 2023
16153b3
test(NODE-4877): Exclude tests from single servers
W-A-James Feb 17, 2023
733ce4a
fix(NODE-4877): Undo unneeded change
W-A-James Feb 17, 2023
c5c94ae
style(NODE-4877): Revert unneeded style change
W-A-James Feb 21, 2023
c7ad82c
fix(NODE-4877): Revert unneeded change to unused function
W-A-James Feb 21, 2023
f29d8f5
chore(NODE-4877): Bump bson version
W-A-James Feb 21, 2023
e5b0430
test(NODE-4877): Make test more idiomatic
W-A-James Feb 21, 2023
5073ce3
fix(NODE-4877): Add bigint to mongo IntegerType and NestedPaths
W-A-James Feb 21, 2023
4f50116
test(NODE-4877): Remove unneeded NOTE comment
W-A-James Feb 21, 2023
35c7a2c
test(NODE-4877): Add tests to check that BSONErrors get thrown
W-A-James Feb 21, 2023
01447c7
fix(NODE-4877): Add check for existence of options.promoteLongs and o…
W-A-James Feb 21, 2023
7e903a3
fix(NODE-4877): fix condition
W-A-James Feb 21, 2023
f178c82
test(NODE-4877): remove setting promoteValues and promoteLongs
W-A-James Feb 21, 2023
61e1370
test(NODE-4877): Remove explicit calls to connect
W-A-James Feb 21, 2023
efcf0b9
style(NODE-4877): eslint
W-A-James Feb 21, 2023
3485472
Update test/integration/change-streams/change_stream.test.ts
W-A-James Feb 22, 2023
3e3aef3
test(NODE-4877): test reorganization
W-A-James Feb 22, 2023
f33339f
test(NODE-4877): Add operation-level option superceding tests
W-A-James Feb 22, 2023
c8c0b36
test(NODE-4877): Add type annotations
W-A-James Feb 22, 2023
e4dd63a
Merge branch 'main' into NODE-4877/add-support-for-BSON-useBigInt64-flag
W-A-James Feb 22, 2023
4e3469d
test(NODE-4877): remove unneeded import
W-A-James Feb 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
128 changes: 111 additions & 17 deletions test/integration/node-specific/bson-options/useBigInt64.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should use snake case (use_bigint_64.test.ts) or something similar to follow our existing filenaming convention.


import { Collection, Db, MongoAPIError, MongoClient } from '../../../mongodb';
import { BSON, Collection, Db, MongoAPIError, MongoClient } from '../../../mongodb';
import { setupDatabase } from '../../shared.js';

describe('useBigInt64 option', function () {
Expand Down Expand Up @@ -127,25 +127,119 @@ describe('useBigInt64 option', function () {
});
});

describe('when set to true and promoteLongs is set to false', function () {
it('throws a MongoAPIError', async function () {
expect(() => {
configuration.newClient(configuration.writeConcernMax(), {
useBigInt64: true,
promoteLongs: false
});
}).to.throw(MongoAPIError, /Must request either bigint or Long for int64 deserialization/);
describe('when useBigInt64=true and promoteLongs=false', function () {
let client: MongoClient;

afterEach(async function () {
if (client) {
await client.close();
}
});

describe('when set at client level', function () {
it('throws a MongoAPIError', async function () {
expect(() => {
client = configuration.newClient(configuration.writeConcernMax(), {
useBigInt64: true,
promoteLongs: false
});
}).to.throw(MongoAPIError, /Must request either bigint or Long for int64 deserialization/);
});
});

describe('when set at DB level', function () {
it('throws a BSONError', async function () {
client = configuration.newClient(configuration.writeConcernMax());
await client.connect();
baileympearson marked this conversation as resolved.
Show resolved Hide resolved
const db = client.db('bsonOptions', { promoteLongs: false, useBigInt64: true });
const e = await db.createCollection('bsonError').catch(e => e);
expect(e).to.be.instanceOf(BSON.BSONError);
});
});

describe('when set at collection level', function () {
it('throws a BSONError', async function () {
client = configuration.newClient(configuration.writeConcernMax());
await client.connect();
const db = client.db('bsonOptions');
const e = await db
.createCollection('bsonError', { promoteLongs: false, useBigInt64: true })
.catch(e => e);
expect(e).to.be.instanceOf(BSON.BSONError);
});
});

describe('when set at the operation level', function () {
it('throws a BSONError', async function () {
client = configuration.newClient(configuration.writeConcernMax());
await client.connect();

const db = client.db('bsonOptions');
const coll = db.collection('bsonError');
const e = await coll
.insertOne({ a: 10n }, { promoteLongs: false, useBigInt64: true })
.catch(e => e);

expect(e).to.be.instanceOf(BSON.BSONError);
});
});
});

describe('when set to true and promoteValues is set to false', function () {
it('throws a MongoAPIError', async function () {
expect(() => {
configuration.newClient(configuration.writeConcernMax(), {
useBigInt64: true,
promoteValues: false
});
}).to.throw(MongoAPIError, /Must request either bigint or Long for int64 deserialization/);
describe('when useBigInt64=true and promoteValues=false', function () {
let client: MongoClient;

afterEach(async function () {
if (client) {
await client.close();
}
});

describe('when set at client level', function () {
it('throws a MongoAPIError', async function () {
expect(() => {
client = configuration.newClient(configuration.writeConcernMax(), {
useBigInt64: true,
promoteValues: false
});
}).to.throw(MongoAPIError, /Must request either bigint or Long for int64 deserialization/);
});
});

describe('when set at DB level', function () {
it('throws a BSONError', async function () {
client = configuration.newClient(configuration.writeConcernMax());
await client.connect();
const db = client.db('bsonOptions', { promoteValues: false, useBigInt64: true });
const e = await db.createCollection('bsonError').catch(e => e);
expect(e).to.be.instanceOf(BSON.BSONError);
});
});

describe('when set at collection level', function () {
it('throws a BSONError', async function () {
client = configuration.newClient(configuration.writeConcernMax());
await client.connect();
const db = client.db('bsonOptions');
const e = await db
.createCollection('bsonError', { promoteValues: false, useBigInt64: true })
.catch(e => e);
expect(e).to.be.instanceOf(BSON.BSONError);
});
});

describe('when set at the operation level', function () {
it('throws a BSONError', async function () {
client = configuration.newClient(configuration.writeConcernMax());
await client.connect();

const db = client.db('bsonOptions');
const coll = db.collection('bsonError');
const e = await coll
.insertOne({ a: 10n }, { promoteValues: false, useBigInt64: true })
.catch(e => e);

expect(e).to.be.instanceOf(BSON.BSONError);
});
});
});
});