{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/crates.io/pulls/comments/106783924","pull_request_review_id":27727100,"id":106783924,"diff_hunk":"@@ -64,28 +64,16 @@ impl<'a> NewUser<'a> {\n \n     /// Inserts the user into the database, or updates an existing one.\n     pub fn create_or_update(&self, conn: &PgConnection) -> CargoResult<User> {\n-        use diesel::{insert, update};\n+        use diesel::insert;\n+        use diesel::expression::dsl::sql;\n+        use diesel::types::Integer;\n         use diesel::pg::upsert::*;\n-        use self::users::dsl::*;\n-\n-        conn.transaction(|| {\n-            // FIXME: When Diesel 0.12 is released, this should be updated to be\n-            // less racy.\n-            // insert(&self.on_conflict(gh_id, do_update().set(self)))\n-            //     .into(users)\n-            //     .get_result(conn)\n-            let maybe_inserted = insert(&self.on_conflict_do_nothing())\n-                .into(users)\n-                .get_result(conn)\n-                .optional()?;\n-            if let Some(user) = maybe_inserted {\n-                return Ok(user);\n-            }\n-            update(users.filter(gh_id.eq(self.gh_id)))\n-                .set(self)\n-                .get_result(conn)\n-                .map_err(Into::into)\n-        })\n+\n+        let conflict_target = sql::<Integer>(\"(gh_id) WHERE gh_id > 0\");","path":"src/user/mod.rs","position":30,"original_position":30,"commit_id":"0b76fd02bc65cd45b31bb57351d3ae46613781a2","original_commit_id":"0b76fd02bc65cd45b31bb57351d3ae46613781a2","user":{"login":"carols10cents","id":193874,"avatar_url":"https://avatars1.githubusercontent.com/u/193874?v=3","gravatar_id":"","url":"https://api.github.com/users/carols10cents","html_url":"https://github.com/carols10cents","followers_url":"https://api.github.com/users/carols10cents/followers","following_url":"https://api.github.com/users/carols10cents/following{/other_user}","gists_url":"https://api.github.com/users/carols10cents/gists{/gist_id}","starred_url":"https://api.github.com/users/carols10cents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carols10cents/subscriptions","organizations_url":"https://api.github.com/users/carols10cents/orgs","repos_url":"https://api.github.com/users/carols10cents/repos","events_url":"https://api.github.com/users/carols10cents/events{/privacy}","received_events_url":"https://api.github.com/users/carols10cents/received_events","type":"User","site_admin":false},"body":"❤️ ","created_at":"2017-03-18T15:52:10Z","updated_at":"2017-03-18T15:52:10Z","html_url":"https://github.com/rust-lang/crates.io/pull/633#discussion_r106783924","pull_request_url":"https://api.github.com/repos/rust-lang/crates.io/pulls/633","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/crates.io/pulls/comments/106783924"},"html":{"href":"https://github.com/rust-lang/crates.io/pull/633#discussion_r106783924"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/crates.io/pulls/633"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/crates.io/pulls/633","id":111120340,"html_url":"https://github.com/rust-lang/crates.io/pull/633","diff_url":"https://github.com/rust-lang/crates.io/pull/633.diff","patch_url":"https://github.com/rust-lang/crates.io/pull/633.patch","issue_url":"https://api.github.com/repos/rust-lang/crates.io/issues/633","number":633,"state":"open","locked":false,"title":"Update to Diesel 0.12","user":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars1.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-16T17:15:42Z","updated_at":"2017-03-18T15:52:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f0ec57c59d79193a0fd57d40b132d57fc3808b8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/crates.io/pulls/633/commits","review_comments_url":"https://api.github.com/repos/rust-lang/crates.io/pulls/633/comments","review_comment_url":"https://api.github.com/repos/rust-lang/crates.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/crates.io/issues/633/comments","statuses_url":"https://api.github.com/repos/rust-lang/crates.io/statuses/0b76fd02bc65cd45b31bb57351d3ae46613781a2","head":{"label":"sgrif:sg-update-diesel","ref":"sg-update-diesel","sha":"0b76fd02bc65cd45b31bb57351d3ae46613781a2","user":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars1.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"repo":{"id":46133759,"name":"crates.io","full_name":"sgrif/crates.io","owner":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars1.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sgrif/crates.io","description":"Source code for crates.io","fork":true,"url":"https://api.github.com/repos/sgrif/crates.io","forks_url":"https://api.github.com/repos/sgrif/crates.io/forks","keys_url":"https://api.github.com/repos/sgrif/crates.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sgrif/crates.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sgrif/crates.io/teams","hooks_url":"https://api.github.com/repos/sgrif/crates.io/hooks","issue_events_url":"https://api.github.com/repos/sgrif/crates.io/issues/events{/number}","events_url":"https://api.github.com/repos/sgrif/crates.io/events","assignees_url":"https://api.github.com/repos/sgrif/crates.io/assignees{/user}","branches_url":"https://api.github.com/repos/sgrif/crates.io/branches{/branch}","tags_url":"https://api.github.com/repos/sgrif/crates.io/tags","blobs_url":"https://api.github.com/repos/sgrif/crates.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sgrif/crates.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sgrif/crates.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/sgrif/crates.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sgrif/crates.io/statuses/{sha}","languages_url":"https://api.github.com/repos/sgrif/crates.io/languages","stargazers_url":"https://api.github.com/repos/sgrif/crates.io/stargazers","contributors_url":"https://api.github.com/repos/sgrif/crates.io/contributors","subscribers_url":"https://api.github.com/repos/sgrif/crates.io/subscribers","subscription_url":"https://api.github.com/repos/sgrif/crates.io/subscription","commits_url":"https://api.github.com/repos/sgrif/crates.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/sgrif/crates.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/sgrif/crates.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/sgrif/crates.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/sgrif/crates.io/contents/{+path}","compare_url":"https://api.github.com/repos/sgrif/crates.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sgrif/crates.io/merges","archive_url":"https://api.github.com/repos/sgrif/crates.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sgrif/crates.io/downloads","issues_url":"https://api.github.com/repos/sgrif/crates.io/issues{/number}","pulls_url":"https://api.github.com/repos/sgrif/crates.io/pulls{/number}","milestones_url":"https://api.github.com/repos/sgrif/crates.io/milestones{/number}","notifications_url":"https://api.github.com/repos/sgrif/crates.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sgrif/crates.io/labels{/name}","releases_url":"https://api.github.com/repos/sgrif/crates.io/releases{/id}","deployments_url":"https://api.github.com/repos/sgrif/crates.io/deployments","created_at":"2015-11-13T16:32:29Z","updated_at":"2015-11-13T16:32:30Z","pushed_at":"2017-03-18T15:30:57Z","git_url":"git://github.com/sgrif/crates.io.git","ssh_url":"git@github.com:sgrif/crates.io.git","clone_url":"https://github.com/sgrif/crates.io.git","svn_url":"https://github.com/sgrif/crates.io","homepage":"https://crates.io","size":2770,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"15e1c02a5560885ac7c84c9f16832f7b5b15bb34","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars2.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":21365581,"name":"crates.io","full_name":"rust-lang/crates.io","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars2.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/crates.io","description":"Source code for crates.io","fork":false,"url":"https://api.github.com/repos/rust-lang/crates.io","forks_url":"https://api.github.com/repos/rust-lang/crates.io/forks","keys_url":"https://api.github.com/repos/rust-lang/crates.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/crates.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/crates.io/teams","hooks_url":"https://api.github.com/repos/rust-lang/crates.io/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/crates.io/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/crates.io/events","assignees_url":"https://api.github.com/repos/rust-lang/crates.io/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/crates.io/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/crates.io/tags","blobs_url":"https://api.github.com/repos/rust-lang/crates.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/crates.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/crates.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/crates.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/crates.io/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/crates.io/languages","stargazers_url":"https://api.github.com/repos/rust-lang/crates.io/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/crates.io/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/crates.io/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/crates.io/subscription","commits_url":"https://api.github.com/repos/rust-lang/crates.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/crates.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/crates.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/crates.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/crates.io/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/crates.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/crates.io/merges","archive_url":"https://api.github.com/repos/rust-lang/crates.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/crates.io/downloads","issues_url":"https://api.github.com/repos/rust-lang/crates.io/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/crates.io/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/crates.io/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/crates.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/crates.io/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/crates.io/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/crates.io/deployments","created_at":"2014-06-30T20:53:49Z","updated_at":"2017-03-17T17:15:08Z","pushed_at":"2017-03-18T15:42:03Z","git_url":"git://github.com/rust-lang/crates.io.git","ssh_url":"git@github.com:rust-lang/crates.io.git","clone_url":"https://github.com/rust-lang/crates.io.git","svn_url":"https://github.com/rust-lang/crates.io","homepage":"https://crates.io","size":2725,"stargazers_count":490,"watchers_count":490,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":125,"mirror_url":null,"open_issues_count":114,"forks":125,"open_issues":114,"watchers":490,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/crates.io/pulls/633"},"html":{"href":"https://github.com/rust-lang/crates.io/pull/633"},"issue":{"href":"https://api.github.com/repos/rust-lang/crates.io/issues/633"},"comments":{"href":"https://api.github.com/repos/rust-lang/crates.io/issues/633/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/crates.io/pulls/633/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/crates.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/crates.io/pulls/633/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/crates.io/statuses/0b76fd02bc65cd45b31bb57351d3ae46613781a2"}}}}
{"actor":{"display_login":"carols10cents"}}