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

RUST-315 Remove ObjectId::with_timestamp #153

Merged
merged 1 commit into from Apr 8, 2020
Merged

Conversation

saghm
Copy link
Contributor

@saghm saghm commented Apr 3, 2020

No description provided.

tests/modules/oid.rs Show resolved Hide resolved
tests/modules/oid.rs Show resolved Hide resolved
@saghm saghm marked this pull request as ready for review April 3, 2020 20:02
@saghm saghm requested a review from patrickfreed April 3, 2020 20:02
@saghm
Copy link
Contributor Author

saghm commented Apr 8, 2020

To provide some context for why we're doing this: relying on the underlying format of an ObjectId is a bit of an antipattern, as the specification for how ObjectId are generated can change (and has done so in the past), and this is not considered a breaking change for the BSON library, the MongoDB driver, or the database itself. In particular, it's brittle to rely on the timestamp field due to the fact that it relies on the system time of the machine that generates the ObjectId; the time could be different across various machines due to time zone, differing NTP servers being synced to, or even just the machine being purposely configured to have an "incorrect" time. We standardize how ObjectIds are generated to ensure that they'll be unique across different machines and different drivers, but there are no user-facing guarantees about how they'll be generated. Users who need to perform queries over documents created in a certain time range should add a field with the time of insertion (and possibly update that on changes, if desired) and use that field when querying. See the documentation for $currentDate for some details on how this can be done.

@saghm saghm merged commit ab4439b into mongodb:master Apr 8, 2020
@saghm saghm deleted the RUST-315 branch April 8, 2020 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants