#1165 mongo upserts fix