mysociety / popit-api

DEPRECATED - Development on PopIt has stopped and it is no longer being maintained
https://goo.gl/Vvej4Q
Other
17 stars 3 forks source link

Set id last so it doesn't get overwritten when filtering #122

Closed chrismytton closed 9 years ago

chrismytton commented 9 years ago

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

struan commented 9 years ago

Looks fine to me