[CSHARP-92] BsonCollection.InsertBatch(new[] { new BsonDocument{ {_id:-1} } }) fails Created: 04/Nov/10  Updated: 02/Apr/15  Resolved: 05/Nov/10

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 0.7
Fix Version/s: 0.9

Type: Bug Priority: Major - P3
Reporter: huy nguyen Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

windows 7, x64. vs2008sp1. .net 3.5


Backwards Compatibility: Major Change

 Description   

calling

var data = new[] {
new BsonDocument() { {_id:-1} }
};
BsonCollection col = ....
var safe = SafeMode.WaitForReplications(2, TimeSpan.FromSeconds(2));
col.InsertBatch(data, safe);

will throw:
MongoDB.Bson.BsonSerializationException : No idGenerator found for type: System.Int32

This used to work on version 0.5 with my own object CRUD test.



 Comments   
Comment by Robert Stam [ 05/Nov/10 ]

If there is no IIdGenerator for a particular type the driver will just leave the Id value alone (so it's up to the client code to generate unique Ids).

Comment by Robert Stam [ 05/Nov/10 ]

The support for IdGenerators is new in 0.7. I will have to change it to make it optional. You should not be getting the error your are getting.

Of course, if you are assigning your own _ids you will have to make sure that your values for _id are unique or you'll get a duplicate key errors from the database.

Comment by huy nguyen [ 04/Nov/10 ]

Additional note: I am using 4 nodes (total) replica set. Server version is 1.6.3. Of the 4 nodes, 2 are data nodes, 2 are arbiters.

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