Search for _id always returns an iterator with an element
matre opened this issue · comments
The element in the iterator will be null if the ID doesn't exist, but the iterator will say that there is an element.
NitriteBuilder builder = Nitrite.builder();
MVStoreModuleBuilder mvBuilder = MVStoreModule.withConfig();
MVStoreModule mvModule = mvBuilder.build();
builder.loadModule(mvModule);
Nitrite db = builder.openOrCreate();
try {
NitriteCollection items = db.getCollection("items");
Filter nameFilter = FluentFilter.where("name").eq("abc");
DocumentCursor nameCursor = items.find(nameFilter, null);
Iterator<Document> nameIter = nameCursor.iterator();
assertFalse("no document matching name.", nameIter.hasNext());
Filter idFilter = FluentFilter.where("_id").eq("0000000000000000000");
DocumentCursor idCursor = items.find(idFilter, null);
Iterator<Document> idIter = idCursor.iterator();
assertFalse("no document matching ID.", idIter.hasNext());
} finally {
db.close();
}
Thanks for reporting it. Fix will be available at the next 4.3.0-SNAPASHOT build
Fix is available now at 4.3.0-SNAPSHOT