{"action":"created","issue":{"url":"https://api.github.com/repos/mysociety/popit-api/issues/95","labels_url":"https://api.github.com/repos/mysociety/popit-api/issues/95/labels{/name}","comments_url":"https://api.github.com/repos/mysociety/popit-api/issues/95/comments","events_url":"https://api.github.com/repos/mysociety/popit-api/issues/95/events","html_url":"https://github.com/mysociety/popit-api/issues/95","id":49121105,"number":95,"title":"when you PUT custom attributes, removing object members doesn't seem to work","user":{"login":"mhl","id":7907,"avatar_url":"https://avatars.githubusercontent.com/u/7907?v=3","gravatar_id":"","url":"https://api.github.com/users/mhl","html_url":"https://github.com/mhl","followers_url":"https://api.github.com/users/mhl/followers","following_url":"https://api.github.com/users/mhl/following{/other_user}","gists_url":"https://api.github.com/users/mhl/gists{/gist_id}","starred_url":"https://api.github.com/users/mhl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhl/subscriptions","organizations_url":"https://api.github.com/users/mhl/orgs","repos_url":"https://api.github.com/users/mhl/repos","events_url":"https://api.github.com/users/mhl/events{/privacy}","received_events_url":"https://api.github.com/users/mhl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-11-17T17:38:50Z","updated_at":"2015-01-08T16:59:02Z","closed_at":null,"body":"In this case I'm PUTing a person record, with a custom key/value pair:\r\n\r\n```javascript\r\n    \"standing_in\": {\r\n        \"2010\": {\r\n            \"mapit_url\": \"http://mapit.mysociety.org/area/14423\", \r\n            \"name\": \"Edinburgh West\", \r\n            \"post_id\": \"14423\"\r\n        }\r\n    }, \r\n```\r\n\r\nThe PUT appears to succeed, but in the return data under `result`, the attribute is still at its old value:\r\n\r\n```javascript\r\n        \"standing_in\": {\r\n            \"2010\": {\r\n                \"mapit_url\": \"http://mapit.mysociety.org/area/14423\", \r\n                \"name\": \"Edinburgh West\", \r\n                \"post_id\": \"14423\"\r\n            }, \r\n            \"2015\": {\r\n                \"mapit_url\": \"http://mapit.mysociety.org/area/14423\", \r\n                \"name\": \"Edinburgh West\", \r\n                \"post_id\": \"14423\"\r\n            }\r\n        }, \r\n```\r\n\r\nThe complete data being PUT is [here](https://gist.github.com/mhl/1579003640a0d4e64356) - the complete response is [here](https://gist.github.com/mhl/8b6176341237524bb8aa) and a whitespace-insensitive diff of the two is [here](https://gist.github.com/mhl/ae45b72f1fb419147f8e)\r\n\r\nI think this must be just to do with removing key/value pairs from the objects, since I haven't noticed this when adding elements to custom attributes that map to objects.\r\n\r\nMy current popit-api version is:\r\n\r\n```\r\n├─┬ popit-api@0.0.14 (git://github.com/mysociety/popit-api.git#4a1d0bc3b1ad45a333d4c198b317874672027481)\r\n│ ├── async@0.2.10\r\n│ ├── doublemetaphone@0.1.2\r\n│ ├─┬ elasticsearch@1.5.14\r\n│ │ ├─┬ chalk@0.4.0\r\n│ │ │ ├── ansi-styles@1.0.0\r\n│ │ │ ├── has-color@0.1.7\r\n│ │ │ └── strip-ansi@0.1.1\r\n│ │ ├── forever-agent@0.5.2\r\n│ │ ├── lodash-node@2.4.1\r\n│ │ └── when@2.8.0\r\n│ ├── http-accept@0.1.6\r\n│ ├── JSV@4.0.2\r\n│ ├─┬ language-tags@1.0.2\r\n│ │ └── language-subtag-registry@0.3.4\r\n│ ├─┬ mongoose@3.8.17\r\n│ │ ├── hooks@0.2.1\r\n│ │ ├─┬ mongodb@1.4.9\r\n│ │ │ ├─┬ bson@0.2.12\r\n│ │ │ │ └── nan@1.2.0\r\n│ │ │ ├── kerberos@0.0.3\r\n│ │ │ └─┬ readable-stream@1.0.33-1\r\n│ │ │   ├── core-util-is@1.0.1\r\n│ │ │   ├── inherits@2.0.1\r\n│ │ │   ├── isarray@0.0.1\r\n│ │ │   └── string_decoder@0.10.31\r\n│ │ ├── mpath@0.1.1\r\n│ │ ├── mpromise@0.4.3\r\n│ │ ├─┬ mquery@0.8.0\r\n│ │ │ └── debug@0.7.4\r\n│ │ ├── ms@0.1.0\r\n│ │ ├── muri@0.3.1\r\n│ │ ├── regexp-clone@0.0.1\r\n│ │ └── sliced@0.0.5\r\n│ ├── mpath@0.2.1\r\n│ ├── underscore@1.4.4\r\n│ ├── underscore.string@2.3.3\r\n│ └── unorm@1.3.3\r\n```"},"comment":{"url":"https://api.github.com/repos/mysociety/popit-api/issues/comments/69210308","html_url":"https://github.com/mysociety/popit-api/issues/95#issuecomment-69210308","issue_url":"https://api.github.com/repos/mysociety/popit-api/issues/95","id":69210308,"user":{"login":"chrismytton","id":22996,"avatar_url":"https://avatars.githubusercontent.com/u/22996?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismytton","html_url":"https://github.com/chrismytton","followers_url":"https://api.github.com/users/chrismytton/followers","following_url":"https://api.github.com/users/chrismytton/following{/other_user}","gists_url":"https://api.github.com/users/chrismytton/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismytton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismytton/subscriptions","organizations_url":"https://api.github.com/users/chrismytton/orgs","repos_url":"https://api.github.com/users/chrismytton/repos","events_url":"https://api.github.com/users/chrismytton/events{/privacy}","received_events_url":"https://api.github.com/users/chrismytton/received_events","type":"User","site_admin":false},"created_at":"2015-01-08T16:59:02Z","updated_at":"2015-01-08T16:59:02Z","body":"Deleted previous comment as it was on the wrong ticket :disappointed: "}}