-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: 1.3
-
Component/s: None
-
None
-
None
-
Major Change
-
None
-
None
-
None
-
None
-
None
-
None
Steps to reproduce:
1) create unique index:
test.ensureIndex(new BasicDBObject("field", 1), "fieldIndex", true);
2) save object
3) save object
{field : 1, d : 2}Expected: exception on step 3
Detected: no exception. first object stored in DB.
Unit test:
@Test
public void testUniqueViolation() throws UnknownHostException {
Mongo mongo = new Mongo();
mongo.dropDatabase("testdb");
DB db = mongo.getDB("testdb");
DBCollection test = db.getCollection("test");
test.ensureIndex(new BasicDBObject("field", 1), "fieldIndex", true);
test.save(new BasicDBObject("field", 1).append("discriminator", 1));
try
catch (MongoException e) {
}
}