[CSHARP-1529] MongoCollectionSettings.AssignIdOnInsert has no effect Created: 12/Jan/16  Updated: 21/Apr/16  Resolved: 14/Jan/16

Status: Closed
Project: C# Driver
Component/s: Operations
Affects Version/s: 2.2, 2.2.1
Fix Version/s: 2.2.2

Type: Bug Priority: Minor - P4
Reporter: Konstantin Zanev Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

According to the MongoDB documentation: "if the mongod receives a document to insert that does not contain an _id field, mongod will add the _id field that holds an ObjectId." Currently it is not possible to use this feautre of the mongod server, because the above mentioning option is not considered by the driver and ObjectId is always generated on collection insert.

Note: Legacy versions of the driver still support this feature.



 Comments   
Comment by Githook User [ 14/Jan/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1529: New high level API should respect AssignIdOnInsert.
Branch: v2.2.x
https://github.com/mongodb/mongo-csharp-driver/commit/b759efa1ba10454f53d1d7f49597e6a220da0bfc

Comment by Githook User [ 14/Jan/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1529: New high level API should respect AssignIdOnInsert.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/f4883504736d5703cdaf5df76a11bfd3573c046b

Comment by Konstantin Zanev [ 12/Jan/16 ]

You're welcome. Thank you for your quick response.

Comment by Craig Wilson [ 12/Jan/16 ]

Ok, I see the problem. The setting is still there, but it is getting ignored. We'll mark this to be fixed. Thanks for the report.

Craig

Comment by Konstantin Zanev [ 12/Jan/16 ]

Thank you Craig. Please refer to the scenario described by this Stackoverflow post: http://stackoverflow.com/questions/24723954/mongodb-c-sharp-driver-and-server-generated-objectids

This was possible with 1.x, now it isn't.

Comment by Konstantin Zanev [ 12/Jan/16 ]

Priority Major was not really attetened, but I can find how to change it.

Comment by Craig Wilson [ 12/Jan/16 ]

Hi Konstantin,

The driver, when it sees a document to be inserted without an identifer, will always generate the identifier client-side. This has been true for as long as I can remember from the legacy driver version up until now. Are you indicating that you'd wish the driver would not do this and let the server always generate the identifier? If so, could you please explain why? If not, then please restate your question/request as I have misunderstood.

Thanks,
Craig

Generated at Wed Feb 07 21:39:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.