-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(NODE-2944): Reintroduce bson-ext support #2823
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c6fa310
fix(NODE-2944): Reintroduce bson-ext support
nbbeeken 22c3522
test: organize and test all types for roundtrip
nbbeeken e62c508
fix: bson options type test
nbbeeken 9aa4082
fix: bson options type
nbbeeken dd1531b
fix: evg bson ext task
nbbeeken a973508
fix: add bson-ext test script
nbbeeken 06f5643
fix: incorrect npm script
nbbeeken 4ed77b3
fix: make sure nvm sets the correct node version
nbbeeken 4090343
fix: failing BSON Ext test
nbbeeken aadc3ad
test: organize import check into it block
nbbeeken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
[ -s "$PROJECT_DIRECTORY/node-artifacts/nvm/nvm.sh" ] && source "$PROJECT_DIRECTORY"/node-artifacts/nvm/nvm.sh | ||
|
||
set -o xtrace # Write all commands first to stderr | ||
set -o errexit # Exit the script with error if any of the commands fail | ||
|
||
# Supported/used environment variables: | ||
# SSL Set to enable SSL. Defaults to "nossl" | ||
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info) | ||
# TEST_NPM_SCRIPT Script to npm run. Defaults to "check:test" | ||
|
||
MONGODB_URI=${MONGODB_URI:-} | ||
TEST_NPM_SCRIPT=${TEST_NPM_SCRIPT:-check:test} | ||
|
||
# ssl setup | ||
SSL=${SSL:-nossl} | ||
if [ "$SSL" != "nossl" ]; then | ||
export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem" | ||
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem" | ||
fi | ||
|
||
# run tests | ||
echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" | ||
|
||
npm install bson-ext | ||
|
||
export MONGODB_API_VERSION=${MONGODB_API_VERSION} | ||
export MONGODB_URI=${MONGODB_URI} | ||
|
||
npm run "${TEST_NPM_SCRIPT}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1577,7 +1577,7 @@ describe('Insert', function () { | |
var collection = db.collection('bson_types_insert_1'); | ||
|
||
var document = { | ||
symbol: new BSONSymbol('abcdefghijkl'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BSONExt supports deserializing but not serializing this type (which is acceptable for deprecated types). So to make the bson-ext tests pass I've updated this to a string. |
||
string: 'abcdefghijkl', | ||
objid: new ObjectId('abcdefghijkl'), | ||
double: new Double(1), | ||
binary: new Binary(Buffer.from('hello world')), | ||
|
@@ -1590,9 +1590,9 @@ describe('Insert', function () { | |
expect(err).to.not.exist; | ||
test.ok(result); | ||
|
||
collection.findOne({ symbol: new BSONSymbol('abcdefghijkl') }, function (err, doc) { | ||
collection.findOne({ string: 'abcdefghijkl' }, function (err, doc) { | ||
expect(err).to.not.exist; | ||
test.equal('abcdefghijkl', doc.symbol.toString()); | ||
test.equal('abcdefghijkl', doc.string.toString()); | ||
|
||
collection.findOne({ objid: new ObjectId('abcdefghijkl') }, function (err, doc) { | ||
expect(err).to.not.exist; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expectType } from 'tsd'; | ||
import type { BSONSerializeOptions, Document } from '../../src/bson'; | ||
|
||
const options: BSONSerializeOptions = {}; | ||
|
||
expectType<boolean | undefined>(options.checkKeys); | ||
expectType<boolean | undefined>(options.serializeFunctions); | ||
expectType<boolean | undefined>(options.ignoreUndefined); | ||
expectType<boolean | undefined>(options.promoteLongs); | ||
expectType<boolean | undefined>(options.promoteBuffers); | ||
expectType<boolean | undefined>(options.promoteValues); | ||
expectType<Document | undefined>(options.fieldsAsRaw); | ||
|
||
type PermittedBSONOptionKeys = | ||
| 'checkKeys' | ||
| 'serializeFunctions' | ||
| 'ignoreUndefined' | ||
| 'promoteLongs' | ||
| 'promoteBuffers' | ||
| 'promoteValues' | ||
| 'fieldsAsRaw' | ||
| 'raw'; | ||
|
||
const keys = (null as unknown) as PermittedBSONOptionKeys; | ||
// creates an explicit allow list assertion | ||
expectType<keyof BSONSerializeOptions>(keys); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we discovered that Serialize and Deserialize options end up being effectively the same here, so this code can be simplified accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked over this too quickly in our discussion, there is a difference and these keys below are the ones we desire from the underlying BSON library:
serialize options:
checkKeys
serializeFunctions
ignoreUndefined
deserialize options:
promoteLongs
promoteBuffers
promoteValues
fieldsAsRaw
I added a typescript test to cover this expectation.