{"action":"created","issue":{"url":"https://api.github.com/repos/hypothesis/h/issues/3256","repository_url":"https://api.github.com/repos/hypothesis/h","labels_url":"https://api.github.com/repos/hypothesis/h/issues/3256/labels{/name}","comments_url":"https://api.github.com/repos/hypothesis/h/issues/3256/comments","events_url":"https://api.github.com/repos/hypothesis/h/issues/3256/events","html_url":"https://github.com/hypothesis/h/pull/3256","id":151444390,"number":3256,"title":"View and storage code for updating annotations in Postgres","user":{"login":"seanh","id":22498,"avatar_url":"https://avatars.githubusercontent.com/u/22498?v=3","gravatar_id":"","url":"https://api.github.com/users/seanh","html_url":"https://github.com/seanh","followers_url":"https://api.github.com/users/seanh/followers","following_url":"https://api.github.com/users/seanh/following{/other_user}","gists_url":"https://api.github.com/users/seanh/gists{/gist_id}","starred_url":"https://api.github.com/users/seanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanh/subscriptions","organizations_url":"https://api.github.com/users/seanh/orgs","repos_url":"https://api.github.com/users/seanh/repos","events_url":"https://api.github.com/users/seanh/events{/privacy}","received_events_url":"https://api.github.com/users/seanh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-27T17:32:28Z","updated_at":"2016-04-28T17:21:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/hypothesis/h/pulls/3256","html_url":"https://github.com/hypothesis/h/pull/3256","diff_url":"https://github.com/hypothesis/h/pull/3256.diff","patch_url":"https://github.com/hypothesis/h/pull/3256.patch"},"body":"This pull request contains:\r\n\r\n* New `views` and `storage` code for updating annotations in Postgres.\r\n\r\n* New code to index annotation updates into the new Es index synchronously\r\n\r\n* Bug fix: don't crash when fetching an annotation with an invalid ID from postgres (iirc this happens when creating an annotation with an invalid ID in its references)\r\n\r\n* Changes to the `schemas` code for updating annotations in Postgres, which had already been merged into master. To be compatible with the legacy behaviour we need to allow partial updates (sort of `PATCH`-like) when only some of the fields of an annotation are sent in an update annotation request. On master if you omit the tags field in an update for example, for the postgres storage it will do the same thing it does on a create: it will replace any existing tags with the default value which is an empty list. Same for the rest of the fields. But the legacy behaviour in this instance is that if no tags are passed in an update (not even an empty list) then _don't change the annotation's tags_.\r\n\r\n   Updating the Postgres code to match the legacy code in this regard is actually a change to `schemas` not to `storage`. `storage` just accepts whatever fields it gets from `schemas` and saves them to the model, so if `schemas` sends `'tags': []` then `storage` will overwrite the annotation's existing tags with an empty list. So we change schemas to send no `'tags'` key in the data, if none was sent in the request.\r\n\r\n* Change to `schemas` which so that it prevents you from changing the references or group of an annotation by deleting these from the data before it gets sent to `storage`. <del>That is unfortunately currently mixed in with other changes in a commit whose commit message describes only those other changes, I'll split it out tomorrow.</del> (done)\r\n\r\n* Change to `schemas` so that `permissions` is no longer a required field for creates and updates. Makes it consistent with the rest of the fields"},"comment":{"url":"https://api.github.com/repos/hypothesis/h/issues/comments/215500676","html_url":"https://github.com/hypothesis/h/pull/3256#issuecomment-215500676","issue_url":"https://api.github.com/repos/hypothesis/h/issues/3256","id":215500676,"user":{"login":"seanh","id":22498,"avatar_url":"https://avatars.githubusercontent.com/u/22498?v=3","gravatar_id":"","url":"https://api.github.com/users/seanh","html_url":"https://github.com/seanh","followers_url":"https://api.github.com/users/seanh/followers","following_url":"https://api.github.com/users/seanh/following{/other_user}","gists_url":"https://api.github.com/users/seanh/gists{/gist_id}","starred_url":"https://api.github.com/users/seanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanh/subscriptions","organizations_url":"https://api.github.com/users/seanh/orgs","repos_url":"https://api.github.com/users/seanh/repos","events_url":"https://api.github.com/users/seanh/events{/privacy}","received_events_url":"https://api.github.com/users/seanh/received_events","type":"User","site_admin":false},"created_at":"2016-04-28T17:21:32Z","updated_at":"2016-04-28T17:21:32Z","body":"This is ready to be reviewed now."}}