-
Notifications
You must be signed in to change notification settings - Fork 254
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-4419): UUID class deserialization #509
Merged
Merged
Conversation
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
aditi-khare-mongoDB
changed the title
added tests
feat(NODE-4419): UUID class deserialization
Jul 26, 2022
nbbeeken
requested changes
Jul 26, 2022
nbbeeken
requested changes
Jul 26, 2022
bajanam
added
the
Primary Review
In Review with primary reviewer, not yet ready for team's eyes
label
Jul 27, 2022
durran
requested changes
Jul 27, 2022
durran
previously approved these changes
Jul 29, 2022
durran
added
Team Review
Needs review from team
and removed
Primary Review
In Review with primary reviewer, not yet ready for team's eyes
labels
Jul 29, 2022
Have Evergreen failures on Node 10 and lower due to |
aditi-khare-mongoDB
force-pushed
the
NODE-4419-deserialize-promoteUUID
branch
from
August 2, 2022 15:38
8e7bd16
to
d68a097
Compare
nbbeeken
approved these changes
Aug 2, 2022
yeah, I've installed a new flatMap dependency that fixed this problem! |
cbush
pushed a commit
to mongodb/docs-realm
that referenced
this pull request
Jan 30, 2023
<h3>Snyk has created this PR to upgrade bson from 4.7.0 to 4.7.1.</h3> :information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project. <hr/> - The recommended version is **1 version** ahead of your current version. - The recommended version was released **21 days ago**, on 2023-01-05. <details> <summary><b>Release notes</b></summary> <br/> <details> <summary>Package name: <b>bson</b></summary> <ul> <li> <b>4.7.1</b> - <a href="https://snyk.io/redirect/github/mongodb/js-bson/releases/tag/v4.7.1">2023-01-05</a></br><p>The MongoDB Node.js team is pleased to announce version v4.7.1 of the bson package!</p> <h3>Bug Fixes</h3> <ul> <li><strong><a class="issue-link js-issue-link notranslate" rel="noopener noreferrer nofollow" href="https://jira.mongodb.org/browse/NODE-4905">NODE-4905</a>:</strong> double precision accuracy in canonical EJSON (<a href="https://snyk.io/redirect/github/mongodb/js-bson/issues/549" data-hovercard-type="pull_request" data-hovercard-url="/mongodb/js-bson/pull/549/hovercard">#549</a>) (<a href="https://snyk.io/redirect/github/mongodb/js-bson/commit/d86bd52661e7f5d26479f6b63acac7950f505d69">d86bd52</a>)</li> </ul> <h2>Documentation</h2> <ul> <li>API: <a href="https://snyk.io/redirect/github/mongodb/js-bson#readme">https:/mongodb/js-bson#readme</a></li> <li>Changelog: <a href="https://snyk.io/redirect/github/mongodb/js-bson/blob/4.0/HISTORY.md#change-log">https:/mongodb/js-bson/blob/4.0/HISTORY.md#change-log</a></li> </ul> <p>We invite you to try the bson library immediately, and report any issues to the <a href="https://jira.mongodb.org/projects/NODE" rel="nofollow">NODE project</a>.</p> </li> <li> <b>4.7.0</b> - <a href="https://snyk.io/redirect/github/mongodb/js-bson/releases/tag/v4.7.0">2022-08-18</a></br><p>The MongoDB Node.js team is pleased to announce version 4.7.0 of the bson package!</p> <h2>Release Highlights</h2> <p>This release adds <em>automatic</em> UUID support. Now when serializing or deserializing BSON you can work directly with the UUID type without explicit conversion methods. The UUID class is now a subclass of binary so all existing code will continue to work (including the explicit conversion methods <code>.toUUID</code>/<code>.toBinary</code>). The same automatic support for UUID is also present in EJSON <code>.parse</code>/<code>.stringify</code>.</p> <p>Take a look at the following for the expected behavior:</p> <div class="highlight highlight-source-ts notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const document = BSON.deserialize(bytes) // { uuid: UUID('xxx') } BSON.serialize(document) // Buffer < document with uuid (binary subtype 4) >"><pre><span class="pl-k">const</span> <span class="pl-smi">document</span> <span class="pl-c1">=</span> <span class="pl-smi">BSON</span><span class="pl-kos">.</span><span class="pl-en">deserialize</span><span class="pl-kos">(</span><span class="pl-s1">bytes</span><span class="pl-kos">)</span> <span class="pl-c">// { uuid: UUID('xxx') }</span> <span class="pl-smi">BSON</span><span class="pl-kos">.</span><span class="pl-en">serialize</span><span class="pl-kos">(</span><span class="pl-smi">document</span><span class="pl-kos">)</span> <span class="pl-c">// Buffer < document with uuid (binary subtype 4) ></span></pre></div> <p>Special thanks to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/aditi-khare-mongoDB/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/aditi-khare-mongoDB">@ aditi-khare-mongoDB</a> for all her hard work on this feature!! <g-emoji class="g-emoji" alias="tada" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f389.png">🎉</g-emoji></p> <h3>Features</h3> <ul> <li><strong><a class="issue-link js-issue-link notranslate" rel="noopener noreferrer nofollow" href="https://jira.mongodb.org/browse/NODE-4405">NODE-4405</a>:</strong> support serializing UUID class (<a href="https://snyk.io/redirect/github/mongodb/js-bson/issues/508" data-hovercard-type="pull_request" data-hovercard-url="/mongodb/js-bson/pull/508/hovercard">#508</a>) (<a href="https://snyk.io/redirect/github/mongodb/js-bson/commit/f5dc9edf915cc119f02f53ec84d1c640695dced7">f5dc9ed</a>)</li> <li><strong><a class="issue-link js-issue-link notranslate" rel="noopener noreferrer nofollow" href="https://jira.mongodb.org/browse/NODE-4419">NODE-4419</a>:</strong> UUID class deserialization (<a href="https://snyk.io/redirect/github/mongodb/js-bson/issues/509" data-hovercard-type="pull_request" data-hovercard-url="/mongodb/js-bson/pull/509/hovercard">#509</a>) (<a href="https://snyk.io/redirect/github/mongodb/js-bson/commit/ff2b97585848730fcf90cd21c14ba2a18a0ed016">ff2b975</a>)</li> <li><strong><a class="issue-link js-issue-link notranslate" rel="noopener noreferrer nofollow" href="https://jira.mongodb.org/browse/NODE-4506">NODE-4506</a>:</strong> Make UUID a subclass of binary (<a href="https://snyk.io/redirect/github/mongodb/js-bson/issues/512" data-hovercard-type="pull_request" data-hovercard-url="/mongodb/js-bson/pull/512/hovercard">#512</a>) (<a href="https://snyk.io/redirect/github/mongodb/js-bson/commit/e9afa9dcfc295da8ff53b28658835fc76cde557c">e9afa9d</a>)</li> <li><strong><a class="issue-link js-issue-link notranslate" rel="noopener noreferrer nofollow" href="https://jira.mongodb.org/browse/NODE-4535">NODE-4535</a>:</strong> automatically promote UUIDs when deserializing and parsing UUIDs (<a href="https://snyk.io/redirect/github/mongodb/js-bson/issues/513" data-hovercard-type="pull_request" data-hovercard-url="/mongodb/js-bson/pull/513/hovercard">#513</a>) (<a href="https://snyk.io/redirect/github/mongodb/js-bson/commit/1dc7eaea6a61924be66ae5b8a05b74d5dd9c7b1e">1dc7eae</a>)</li> </ul> <hr> <h2>Documentation</h2> <ul> <li>API: <a href="https://snyk.io/redirect/github/mongodb/js-bson#readme">https:/mongodb/js-bson#readme</a></li> <li>Changelog: <a href="https://snyk.io/redirect/github/mongodb/js-bson/blob/main/HISTORY.md#change-log">https:/mongodb/js-bson/blob/main/HISTORY.md#change-log</a></li> </ul> <p>We invite you to try the bson library immediately, and report any issues to the <a href="https://jira.mongodb.org/projects/NODE" rel="nofollow">NODE project</a>.</p> </li> </ul> from <a href="https://snyk.io/redirect/github/mongodb/js-bson/releases">bson GitHub release notes</a> </details> </details> <details> <summary><b>Commit messages</b></summary> </br> <details> <summary>Package name: <b>bson</b></summary> <ul> <li><a href="https://snyk.io/redirect/github/mongodb/js-bson/commit/5465c33b356ceaed05c1759007acdf3ab077ee33">5465c33</a> chore(release): 4.7.1</li> <li><a href="https://snyk.io/redirect/github/mongodb/js-bson/commit/d86bd52661e7f5d26479f6b63acac7950f505d69">d86bd52</a> fix(NODE-4905): double precision accuracy in canonical EJSON (#549)</li> </ul> <a href="https://snyk.io/redirect/github/mongodb/js-bson/compare/853bbb0441b0e29e5277cd191b515d5a884d8d21...5465c33b356ceaed05c1759007acdf3ab077ee33">Compare</a> </details> </details> <hr/> **Note:** *You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.* For more information: <img src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiIzOTdmMzA0MS1kMTJmLTQ4MDMtODIyNC1iNDY4MmQ0YzU4NjgiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjM5N2YzMDQxLWQxMmYtNDgwMy04MjI0LWI0NjgyZDRjNTg2OCJ9fQ==" width="0" height="0"/> 🧐 [View latest project report](https://app.snyk.io/org/sandbox-2ba/project/852e6e4f-be96-45c8-b370-1060f5ebee55?utm_source=github&utm_medium=referral&page=upgrade-pr) 🛠 [Adjust upgrade PR settings](https://app.snyk.io/org/sandbox-2ba/project/852e6e4f-be96-45c8-b370-1060f5ebee55/settings/integration?utm_source=github&utm_medium=referral&page=upgrade-pr) 🔕 [Ignore this dependency or unsubscribe from future upgrade PRs](https://app.snyk.io/org/sandbox-2ba/project/852e6e4f-be96-45c8-b370-1060f5ebee55/settings/integration?pkg=bson&utm_source=github&utm_medium=referral&page=upgrade-pr#auto-dep-upgrades) <!--- (snyk:metadata:{"prId":"397f3041-d12f-4803-8224-b4682d4c5868","prPublicId":"397f3041-d12f-4803-8224-b4682d4c5868","dependencies":[{"name":"bson","from":"4.7.0","to":"4.7.1"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/sandbox-2ba/project/852e6e4f-be96-45c8-b370-1060f5ebee55?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"852e6e4f-be96-45c8-b370-1060f5ebee55","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":1,"publishedDate":"2023-01-05T15:16:00.352Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]}) ---> --------- Co-authored-by: snyk-bot <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
When deserializing a UUID object, the user can use the boolean option
promoteUUIDs
to return an object of type UUID. This is part of an ongoing project to better integrate the use of the UUID class into js-bson.What is changing?
There is a new option
promoteUUIDs
available to users when deserializing objections.Is there new documentation needed for these changes?
If the existing object is of the UUID subtype, and the flag is true (ex:
{promoteUUIDs: true}
), then the resulting deserialization will return a UUID object. If the flag is false, or omitted it will return a binary object.What is the motivation for this change?
After deserializing, users can now have UUID objects.
Double check the following
npm run lint
script<type>(NODE-xxxx)<!>: <description>