[DRIVERS-2073] Codify driver support for client-side ObjectID generation Created: 29/Oct/19  Updated: 31/Mar/22

Status: Backlog
Project: Drivers
Component/s: CRUD
Fix Version/s: None

Type: Spec Change Priority: Major - P3
Reporter: Daniel Aprahamian (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Driver Changes: Needed

 Description   

Currently behavior in drivers is as follows:

  • If there is no _id present on an insert, drivers will generate an _id as a bson ObjectId.

What is currently not specified and/or universal:

  • Should drivers generate a client-side objectID for upserts using either update or findAndModify (AFAIK no driver does this)
  • Should drivers support the ability to disable client-side _id generation (currently Node supports this via the forceServerObjectId option. I do not know of another driver that does)
  • Should drivers support the ability to change the type of the _id generated at the collection/db/client level? (Node currently supports passing a pkFactory that will be used to generate all client-side {{_id}}s)

We should be able to answer the above questions, and codify behavior across drivers for client-side _id generation.



 Comments   
Comment by Bernie Hackett [ 29/Oct/19 ]

Another thing to clarify:

  • Should drivers be prohibited from modifying the original document to add the _id?

PyMongo currently adds the _id to the document passed by the application. That has caused a lot of confusion over the years.

Generated at Thu Feb 08 08:24:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.