{"action":"created","comment":{"url":"https://api.github.com/repos/hypothesis/h/pulls/comments/62316225","id":62316225,"diff_hunk":"@@ -264,17 +192,50 @@ class CreateAnnotationSchema(object):\n     \"\"\"Validate the POSTed data of a create annotation request.\"\"\"\n \n     def __init__(self, request):\n-        self.structure = AnnotationSchema(request)\n+        self.structure = AnnotationSchema()\n+        self.request = request\n \n     def validate(self, data):\n-        return self.structure.validate(data)\n+        appstruct = self.structure.validate(data)\n+\n+        new_appstruct = {}\n+\n+        _remove_protected_fields(appstruct)\n+\n+        new_appstruct['userid'] = self.request.authenticated_userid\n+        new_appstruct['target_uri'] = appstruct.pop('uri', u'')\n+        new_appstruct['text'] = appstruct.pop('text', u'')","path":"h/api/schemas.py","position":120,"original_position":120,"commit_id":"01beec97f1cf773903d0ecc5ce5d77df12743942","original_commit_id":"01beec97f1cf773903d0ecc5ce5d77df12743942","user":{"login":"chdorner","id":112063,"avatar_url":"https://avatars.githubusercontent.com/u/112063?v=3","gravatar_id":"","url":"https://api.github.com/users/chdorner","html_url":"https://github.com/chdorner","followers_url":"https://api.github.com/users/chdorner/followers","following_url":"https://api.github.com/users/chdorner/following{/other_user}","gists_url":"https://api.github.com/users/chdorner/gists{/gist_id}","starred_url":"https://api.github.com/users/chdorner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chdorner/subscriptions","organizations_url":"https://api.github.com/users/chdorner/orgs","repos_url":"https://api.github.com/users/chdorner/repos","events_url":"https://api.github.com/users/chdorner/events{/privacy}","received_events_url":"https://api.github.com/users/chdorner/received_events","type":"User","site_admin":false},"body":"Yes. Was just going through the default values we set here and the default values/(not-)NULL constraints on the database. We do allow `NULL` on the `text` column, so there's no need to store an empty string. At some later point we might want to assume that an empty string is considered `NULL` as well, which would make querying easier. But that might have other implications and is a whole different discussion :)","created_at":"2016-05-06T11:05:52Z","updated_at":"2016-05-06T11:05:52Z","html_url":"https://github.com/hypothesis/h/pull/3280#discussion_r62316225","pull_request_url":"https://api.github.com/repos/hypothesis/h/pulls/3280","_links":{"self":{"href":"https://api.github.com/repos/hypothesis/h/pulls/comments/62316225"},"html":{"href":"https://github.com/hypothesis/h/pull/3280#discussion_r62316225"},"pull_request":{"href":"https://api.github.com/repos/hypothesis/h/pulls/3280"}}},"pull_request":{"url":"https://api.github.com/repos/hypothesis/h/pulls/3280","id":69019867,"html_url":"https://github.com/hypothesis/h/pull/3280","diff_url":"https://github.com/hypothesis/h/pull/3280.diff","patch_url":"https://github.com/hypothesis/h/pull/3280.patch","issue_url":"https://api.github.com/repos/hypothesis/h/issues/3280","number":3280,"state":"open","locked":false,"title":"Schemas 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},"body":"A few changes to `h.api.schemas` related to updating annotations in Postgres:\r\n\r\n- Do partial updates in the same way the legacy Es schemas/storage do https://github.com/hypothesis/h/pull/3280/commits/0d58f63a3f58c6d5364859acc5d3ab3bd2de4375\r\n- Don't allow changing group or references in update, handle this in schemas so storage doesn't worry about it https://github.com/hypothesis/h/pull/3280/commits/caa4d5e4bb41a67b07d662420890f5082fb7c508\r\n- Make permissions optional https://github.com/hypothesis/h/pull/3280/commits/127263a2c97ab7f1d2d91fa8bf517a685f55f2a8\r\n- As well as some pep8 and lint, some bug fixes, and some changes previously requested and made on https://github.com/hypothesis/h/pull/3256\r\n\r\nSo this is a bit of a grab-bag. I could try to split this up into yet smaller PRs but hopefully this is small enough if reviewed commit by commit.","created_at":"2016-05-05T15:05:45Z","updated_at":"2016-05-06T11:05:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2beec048422c7045d7ac755e0818aa71d87aea32","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hypothesis/h/pulls/3280/commits","review_comments_url":"https://api.github.com/repos/hypothesis/h/pulls/3280/comments","review_comment_url":"https://api.github.com/repos/hypothesis/h/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hypothesis/h/issues/3280/comments","statuses_url":"https://api.github.com/repos/hypothesis/h/statuses/01beec97f1cf773903d0ecc5ce5d77df12743942","head":{"label":"hypothesis:schemas-code-for-updating-annotations-in-postgres","ref":"schemas-code-for-updating-annotations-in-postgres","sha":"01beec97f1cf773903d0ecc5ce5d77df12743942","user":{"login":"hypothesis","id":1243215,"avatar_url":"https://avatars.githubusercontent.com/u/1243215?v=3","gravatar_id":"","url":"https://api.github.com/users/hypothesis","html_url":"https://github.com/hypothesis","followers_url":"https://api.github.com/users/hypothesis/followers","following_url":"https://api.github.com/users/hypothesis/following{/other_user}","gists_url":"https://api.github.com/users/hypothesis/gists{/gist_id}","starred_url":"https://api.github.com/users/hypothesis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hypothesis/subscriptions","organizations_url":"https://api.github.com/users/hypothesis/orgs","repos_url":"https://api.github.com/users/hypothesis/repos","events_url":"https://api.github.com/users/hypothesis/events{/privacy}","received_events_url":"https://api.github.com/users/hypothesis/received_events","type":"Organization","site_admin":false},"repo":{"id":3910945,"name":"h","full_name":"hypothesis/h","owner":{"login":"hypothesis","id":1243215,"avatar_url":"https://avatars.githubusercontent.com/u/1243215?v=3","gravatar_id":"","url":"https://api.github.com/users/hypothesis","html_url":"https://github.com/hypothesis","followers_url":"https://api.github.com/users/hypothesis/followers","following_url":"https://api.github.com/users/hypothesis/following{/other_user}","gists_url":"https://api.github.com/users/hypothesis/gists{/gist_id}","starred_url":"https://api.github.com/users/hypothesis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hypothesis/subscriptions","organizations_url":"https://api.github.com/users/hypothesis/orgs","repos_url":"https://api.github.com/users/hypothesis/repos","events_url":"https://api.github.com/users/hypothesis/events{/privacy}","received_events_url":"https://api.github.com/users/hypothesis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hypothesis/h","description":"The Internet, peer reviewed.","fork":false,"url":"https://api.github.com/repos/hypothesis/h","forks_url":"https://api.github.com/repos/hypothesis/h/forks","keys_url":"https://api.github.com/repos/hypothesis/h/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hypothesis/h/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hypothesis/h/teams","hooks_url":"https://api.github.com/repos/hypothesis/h/hooks","issue_events_url":"https://api.github.com/repos/hypothesis/h/issues/events{/number}","events_url":"https://api.github.com/repos/hypothesis/h/events","assignees_url":"https://api.github.com/repos/hypothesis/h/assignees{/user}","branches_url":"https://api.github.com/repos/hypothesis/h/branches{/branch}","tags_url":"https://api.github.com/repos/hypothesis/h/tags","blobs_url":"https://api.github.com/repos/hypothesis/h/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hypothesis/h/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hypothesis/h/git/refs{/sha}","trees_url":"https://api.github.com/repos/hypothesis/h/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hypothesis/h/statuses/{sha}","languages_url":"https://api.github.com/repos/hypothesis/h/languages","stargazers_url":"https://api.github.com/repos/hypothesis/h/stargazers","contributors_url":"https://api.github.com/repos/hypothesis/h/contributors","subscribers_url":"https://api.github.com/repos/hypothesis/h/subscribers","subscription_url":"https://api.github.com/repos/hypothesis/h/subscription","commits_url":"https://api.github.com/repos/hypothesis/h/commits{/sha}","git_commits_url":"https://api.github.com/repos/hypothesis/h/git/commits{/sha}","comments_url":"https://api.github.com/repos/hypothesis/h/comments{/number}","issue_comment_url":"https://api.github.com/repos/hypothesis/h/issues/comments{/number}","contents_url":"https://api.github.com/repos/hypothesis/h/contents/{+path}","compare_url":"https://api.github.com/repos/hypothesis/h/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hypothesis/h/merges","archive_url":"https://api.github.com/repos/hypothesis/h/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hypothesis/h/downloads","issues_url":"https://api.github.com/repos/hypothesis/h/issues{/number}","pulls_url":"https://api.github.com/repos/hypothesis/h/pulls{/number}","milestones_url":"https://api.github.com/repos/hypothesis/h/milestones{/number}","notifications_url":"https://api.github.com/repos/hypothesis/h/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hypothesis/h/labels{/name}","releases_url":"https://api.github.com/repos/hypothesis/h/releases{/id}","deployments_url":"https://api.github.com/repos/hypothesis/h/deployments","created_at":"2012-04-02T19:56:59Z","updated_at":"2016-05-05T22:54:31Z","pushed_at":"2016-05-06T10:38:26Z","git_url":"git://github.com/hypothesis/h.git","ssh_url":"git@github.com:hypothesis/h.git","clone_url":"https://github.com/hypothesis/h.git","svn_url":"https://github.com/hypothesis/h","homepage":"https://hypothes.is/","size":28444,"stargazers_count":631,"watchers_count":631,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":148,"mirror_url":null,"open_issues_count":66,"forks":148,"open_issues":66,"watchers":631,"default_branch":"master"}},"base":{"label":"hypothesis:master","ref":"master","sha":"c3f4c2883ce4c21505c22317404c061e7f86ebe7","user":{"login":"hypothesis","id":1243215,"avatar_url":"https://avatars.githubusercontent.com/u/1243215?v=3","gravatar_id":"","url":"https://api.github.com/users/hypothesis","html_url":"https://github.com/hypothesis","followers_url":"https://api.github.com/users/hypothesis/followers","following_url":"https://api.github.com/users/hypothesis/following{/other_user}","gists_url":"https://api.github.com/users/hypothesis/gists{/gist_id}","starred_url":"https://api.github.com/users/hypothesis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hypothesis/subscriptions","organizations_url":"https://api.github.com/users/hypothesis/orgs","repos_url":"https://api.github.com/users/hypothesis/repos","events_url":"https://api.github.com/users/hypothesis/events{/privacy}","received_events_url":"https://api.github.com/users/hypothesis/received_events","type":"Organization","site_admin":false},"repo":{"id":3910945,"name":"h","full_name":"hypothesis/h","owner":{"login":"hypothesis","id":1243215,"avatar_url":"https://avatars.githubusercontent.com/u/1243215?v=3","gravatar_id":"","url":"https://api.github.com/users/hypothesis","html_url":"https://github.com/hypothesis","followers_url":"https://api.github.com/users/hypothesis/followers","following_url":"https://api.github.com/users/hypothesis/following{/other_user}","gists_url":"https://api.github.com/users/hypothesis/gists{/gist_id}","starred_url":"https://api.github.com/users/hypothesis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hypothesis/subscriptions","organizations_url":"https://api.github.com/users/hypothesis/orgs","repos_url":"https://api.github.com/users/hypothesis/repos","events_url":"https://api.github.com/users/hypothesis/events{/privacy}","received_events_url":"https://api.github.com/users/hypothesis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hypothesis/h","description":"The Internet, peer reviewed.","fork":false,"url":"https://api.github.com/repos/hypothesis/h","forks_url":"https://api.github.com/repos/hypothesis/h/forks","keys_url":"https://api.github.com/repos/hypothesis/h/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hypothesis/h/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hypothesis/h/teams","hooks_url":"https://api.github.com/repos/hypothesis/h/hooks","issue_events_url":"https://api.github.com/repos/hypothesis/h/issues/events{/number}","events_url":"https://api.github.com/repos/hypothesis/h/events","assignees_url":"https://api.github.com/repos/hypothesis/h/assignees{/user}","branches_url":"https://api.github.com/repos/hypothesis/h/branches{/branch}","tags_url":"https://api.github.com/repos/hypothesis/h/tags","blobs_url":"https://api.github.com/repos/hypothesis/h/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hypothesis/h/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hypothesis/h/git/refs{/sha}","trees_url":"https://api.github.com/repos/hypothesis/h/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hypothesis/h/statuses/{sha}","languages_url":"https://api.github.com/repos/hypothesis/h/languages","stargazers_url":"https://api.github.com/repos/hypothesis/h/stargazers","contributors_url":"https://api.github.com/repos/hypothesis/h/contributors","subscribers_url":"https://api.github.com/repos/hypothesis/h/subscribers","subscription_url":"https://api.github.com/repos/hypothesis/h/subscription","commits_url":"https://api.github.com/repos/hypothesis/h/commits{/sha}","git_commits_url":"https://api.github.com/repos/hypothesis/h/git/commits{/sha}","comments_url":"https://api.github.com/repos/hypothesis/h/comments{/number}","issue_comment_url":"https://api.github.com/repos/hypothesis/h/issues/comments{/number}","contents_url":"https://api.github.com/repos/hypothesis/h/contents/{+path}","compare_url":"https://api.github.com/repos/hypothesis/h/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hypothesis/h/merges","archive_url":"https://api.github.com/repos/hypothesis/h/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hypothesis/h/downloads","issues_url":"https://api.github.com/repos/hypothesis/h/issues{/number}","pulls_url":"https://api.github.com/repos/hypothesis/h/pulls{/number}","milestones_url":"https://api.github.com/repos/hypothesis/h/milestones{/number}","notifications_url":"https://api.github.com/repos/hypothesis/h/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hypothesis/h/labels{/name}","releases_url":"https://api.github.com/repos/hypothesis/h/releases{/id}","deployments_url":"https://api.github.com/repos/hypothesis/h/deployments","created_at":"2012-04-02T19:56:59Z","updated_at":"2016-05-05T22:54:31Z","pushed_at":"2016-05-06T10:38:26Z","git_url":"git://github.com/hypothesis/h.git","ssh_url":"git@github.com:hypothesis/h.git","clone_url":"https://github.com/hypothesis/h.git","svn_url":"https://github.com/hypothesis/h","homepage":"https://hypothes.is/","size":28444,"stargazers_count":631,"watchers_count":631,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":148,"mirror_url":null,"open_issues_count":66,"forks":148,"open_issues":66,"watchers":631,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hypothesis/h/pulls/3280"},"html":{"href":"https://github.com/hypothesis/h/pull/3280"},"issue":{"href":"https://api.github.com/repos/hypothesis/h/issues/3280"},"comments":{"href":"https://api.github.com/repos/hypothesis/h/issues/3280/comments"},"review_comments":{"href":"https://api.github.com/repos/hypothesis/h/pulls/3280/comments"},"review_comment":{"href":"https://api.github.com/repos/hypothesis/h/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hypothesis/h/pulls/3280/commits"},"statuses":{"href":"https://api.github.com/repos/hypothesis/h/statuses/01beec97f1cf773903d0ecc5ce5d77df12743942"}}}}