The filter module was setting the id property of the returned document
first, then proceeding to iterate through the whole document and copy
properties across. This meant that when the document had an 'id' field
that didn't match the '_id' field (for whatever reason) it was
overwriting the 'id' property with an incorrect one.
This fix ensures that the returned document will always have the correct
id property matching the _id in the database. There is still the mystery
of how the ids came to differ in the first place, but at least this
masks that problem.
The filter module was setting the id property of the returned document first, then proceeding to iterate through the whole document and copy properties across. This meant that when the document had an 'id' field that didn't match the '_id' field (for whatever reason) it was overwriting the 'id' property with an incorrect one.
This fix ensures that the returned document will always have the correct id property matching the _id in the database. There is still the mystery of how the ids came to differ in the first place, but at least this masks that problem.
Fixes https://github.com/mysociety/popit/issues/730