Details
-
Bug
-
Resolution: Done
-
Major - P3
-
1.3
-
None
-
None
-
Major Change
Description
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) {
}
}