{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/comments/145790995","pull_request_review_id":70643958,"id":145790995,"diff_hunk":"@@ -1374,21 +1374,32 @@\n         WHERE f.value IS NULL AND fv.value IS NULL\")\n \n   (log/info (trs \"[5/8] Cleaning up duplicate null values...\"))\n-  (let [json-null-value-id (some-> (jdbc/query-to-vec \"select id from fact_values\n-                                                       where value_type_id = 5 and value = 'null'\")\n-                                   first\n-                                   :id)\n-        real-null-value-id (some-> (jdbc/query-to-vec \"select id from fact_values\n-                                                       where value_type_id = 4 and value is null\")\n-                                   first\n-                                   :id)]\n-    (if (and json-null-value-id real-null-value-id)\n-      (do\n-        (jdbc/do-prepared \"update facts_transform set fact_value_id = (?) where fact_value_id = (?)\"\n-                          [real-null-value-id json-null-value-id])\n-        (jdbc/do-prepared \"delete from fact_values where id = (?)\"\n-                          [json-null-value-id]))\n-      (log/info (trs \"  ... none found\"))))\n+  ;; only do this if the DB has some null values\n+  (when (pos? (-> (jdbc/query-to-vec \"select count(*) from fact_values\n+                                      where value_type_id in (4,5)\n+                                      and value in (null, 'null')\")\n+                  first\n+                  :count))\n+   (let [real-null-value-id (let [existing-id (some-> (jdbc/query-to-vec\n+                                                       \"select id from fact_values\n+                                                       where value_type_id=4 and value is null\")\n+                                                      first\n+                                                      :id)]\n+                              (or existing-id\n+                                  (-> (jdbc/query-to-vec\n+                                       \"insert into fact_values (value_type_id, value) values (4, null) returning id\")\n+                                      first\n+                                      :id)))","path":"src/puppetlabs/puppetdb/scf/migrate.clj","position":34,"original_position":34,"commit_id":"ae204209b3af97ec08d04016b6788bdb19c73ba0","original_commit_id":"ae204209b3af97ec08d04016b6788bdb19c73ba0","user":{"login":"wkalt","id":4952091,"avatar_url":"https://avatars1.githubusercontent.com/u/4952091?v=4","gravatar_id":"","url":"https://api.github.com/users/wkalt","html_url":"https://github.com/wkalt","followers_url":"https://api.github.com/users/wkalt/followers","following_url":"https://api.github.com/users/wkalt/following{/other_user}","gists_url":"https://api.github.com/users/wkalt/gists{/gist_id}","starred_url":"https://api.github.com/users/wkalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wkalt/subscriptions","organizations_url":"https://api.github.com/users/wkalt/orgs","repos_url":"https://api.github.com/users/wkalt/repos","events_url":"https://api.github.com/users/wkalt/events{/privacy}","received_events_url":"https://api.github.com/users/wkalt/received_events","type":"User","site_admin":false},"body":"forget the last three comments -- the value types are hardcoded in the migration","created_at":"2017-10-19T18:49:28Z","updated_at":"2017-10-19T18:49:28Z","html_url":"https://github.com/puppetlabs/puppetdb/pull/2380#discussion_r145790995","pull_request_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/2380","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/comments/145790995"},"html":{"href":"https://github.com/puppetlabs/puppetdb/pull/2380#discussion_r145790995"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/2380"}},"in_reply_to_id":145787528},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/2380","id":146905741,"html_url":"https://github.com/puppetlabs/puppetdb/pull/2380","diff_url":"https://github.com/puppetlabs/puppetdb/pull/2380.diff","patch_url":"https://github.com/puppetlabs/puppetdb/pull/2380.patch","issue_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues/2380","number":2380,"state":"open","locked":false,"title":"(PDB-3692) Handle another variant of null value duplication","user":{"login":"mullr","id":24409,"avatar_url":"https://avatars0.githubusercontent.com/u/24409?v=4","gravatar_id":"","url":"https://api.github.com/users/mullr","html_url":"https://github.com/mullr","followers_url":"https://api.github.com/users/mullr/followers","following_url":"https://api.github.com/users/mullr/following{/other_user}","gists_url":"https://api.github.com/users/mullr/gists{/gist_id}","starred_url":"https://api.github.com/users/mullr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mullr/subscriptions","organizations_url":"https://api.github.com/users/mullr/orgs","repos_url":"https://api.github.com/users/mullr/repos","events_url":"https://api.github.com/users/mullr/events{/privacy}","received_events_url":"https://api.github.com/users/mullr/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-10-16T22:43:22Z","updated_at":"2017-10-19T18:49:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8f708166a358221b1c479c210bc878656fbf13ba","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/2380/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/2380/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues/2380/comments","statuses_url":"https://api.github.com/repos/puppetlabs/puppetdb/statuses/ae204209b3af97ec08d04016b6788bdb19c73ba0","head":{"label":"mullr:ticket/5.1.x/pdb-3692-more-duplicate-nulls","ref":"ticket/5.1.x/pdb-3692-more-duplicate-nulls","sha":"ae204209b3af97ec08d04016b6788bdb19c73ba0","user":{"login":"mullr","id":24409,"avatar_url":"https://avatars0.githubusercontent.com/u/24409?v=4","gravatar_id":"","url":"https://api.github.com/users/mullr","html_url":"https://github.com/mullr","followers_url":"https://api.github.com/users/mullr/followers","following_url":"https://api.github.com/users/mullr/following{/other_user}","gists_url":"https://api.github.com/users/mullr/gists{/gist_id}","starred_url":"https://api.github.com/users/mullr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mullr/subscriptions","organizations_url":"https://api.github.com/users/mullr/orgs","repos_url":"https://api.github.com/users/mullr/repos","events_url":"https://api.github.com/users/mullr/events{/privacy}","received_events_url":"https://api.github.com/users/mullr/received_events","type":"User","site_admin":false},"repo":{"id":30666123,"name":"puppetdb","full_name":"mullr/puppetdb","owner":{"login":"mullr","id":24409,"avatar_url":"https://avatars0.githubusercontent.com/u/24409?v=4","gravatar_id":"","url":"https://api.github.com/users/mullr","html_url":"https://github.com/mullr","followers_url":"https://api.github.com/users/mullr/followers","following_url":"https://api.github.com/users/mullr/following{/other_user}","gists_url":"https://api.github.com/users/mullr/gists{/gist_id}","starred_url":"https://api.github.com/users/mullr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mullr/subscriptions","organizations_url":"https://api.github.com/users/mullr/orgs","repos_url":"https://api.github.com/users/mullr/repos","events_url":"https://api.github.com/users/mullr/events{/privacy}","received_events_url":"https://api.github.com/users/mullr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mullr/puppetdb","description":"Centralized Puppet Storage","fork":true,"url":"https://api.github.com/repos/mullr/puppetdb","forks_url":"https://api.github.com/repos/mullr/puppetdb/forks","keys_url":"https://api.github.com/repos/mullr/puppetdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mullr/puppetdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mullr/puppetdb/teams","hooks_url":"https://api.github.com/repos/mullr/puppetdb/hooks","issue_events_url":"https://api.github.com/repos/mullr/puppetdb/issues/events{/number}","events_url":"https://api.github.com/repos/mullr/puppetdb/events","assignees_url":"https://api.github.com/repos/mullr/puppetdb/assignees{/user}","branches_url":"https://api.github.com/repos/mullr/puppetdb/branches{/branch}","tags_url":"https://api.github.com/repos/mullr/puppetdb/tags","blobs_url":"https://api.github.com/repos/mullr/puppetdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mullr/puppetdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mullr/puppetdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/mullr/puppetdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mullr/puppetdb/statuses/{sha}","languages_url":"https://api.github.com/repos/mullr/puppetdb/languages","stargazers_url":"https://api.github.com/repos/mullr/puppetdb/stargazers","contributors_url":"https://api.github.com/repos/mullr/puppetdb/contributors","subscribers_url":"https://api.github.com/repos/mullr/puppetdb/subscribers","subscription_url":"https://api.github.com/repos/mullr/puppetdb/subscription","commits_url":"https://api.github.com/repos/mullr/puppetdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/mullr/puppetdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/mullr/puppetdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/mullr/puppetdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/mullr/puppetdb/contents/{+path}","compare_url":"https://api.github.com/repos/mullr/puppetdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mullr/puppetdb/merges","archive_url":"https://api.github.com/repos/mullr/puppetdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mullr/puppetdb/downloads","issues_url":"https://api.github.com/repos/mullr/puppetdb/issues{/number}","pulls_url":"https://api.github.com/repos/mullr/puppetdb/pulls{/number}","milestones_url":"https://api.github.com/repos/mullr/puppetdb/milestones{/number}","notifications_url":"https://api.github.com/repos/mullr/puppetdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mullr/puppetdb/labels{/name}","releases_url":"https://api.github.com/repos/mullr/puppetdb/releases{/id}","deployments_url":"https://api.github.com/repos/mullr/puppetdb/deployments","created_at":"2015-02-11T19:42:39Z","updated_at":"2016-03-07T19:32:42Z","pushed_at":"2017-10-18T23:06:03Z","git_url":"git://github.com/mullr/puppetdb.git","ssh_url":"git@github.com:mullr/puppetdb.git","clone_url":"https://github.com/mullr/puppetdb.git","svn_url":"https://github.com/mullr/puppetdb","homepage":"http://docs.puppetlabs.com/puppetdb","size":17994,"stargazers_count":0,"watchers_count":0,"language":"Clojure","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"puppetlabs:5.1.x","ref":"5.1.x","sha":"41e41cb1fed950c6ff4c47ca633a34b6ed252bd0","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars0.githubusercontent.com/u/234268?v=4","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":2193032,"name":"puppetdb","full_name":"puppetlabs/puppetdb","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars0.githubusercontent.com/u/234268?v=4","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/puppetdb","description":"Centralized Puppet Storage","fork":false,"url":"https://api.github.com/repos/puppetlabs/puppetdb","forks_url":"https://api.github.com/repos/puppetlabs/puppetdb/forks","keys_url":"https://api.github.com/repos/puppetlabs/puppetdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/puppetdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/puppetdb/teams","hooks_url":"https://api.github.com/repos/puppetlabs/puppetdb/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/puppetdb/events","assignees_url":"https://api.github.com/repos/puppetlabs/puppetdb/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/puppetdb/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/puppetdb/tags","blobs_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/puppetdb/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/puppetdb/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/puppetdb/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/puppetdb/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/puppetdb/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/puppetdb/subscription","commits_url":"https://api.github.com/repos/puppetlabs/puppetdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/puppetdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/puppetdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/puppetdb/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/puppetdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/puppetdb/merges","archive_url":"https://api.github.com/repos/puppetlabs/puppetdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/puppetdb/downloads","issues_url":"https://api.github.com/repos/puppetlabs/puppetdb/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/puppetdb/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/puppetdb/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/puppetdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/puppetdb/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/puppetdb/releases{/id}","deployments_url":"https://api.github.com/repos/puppetlabs/puppetdb/deployments","created_at":"2011-08-11T18:54:46Z","updated_at":"2017-10-19T00:48:41Z","pushed_at":"2017-10-19T09:12:08Z","git_url":"git://github.com/puppetlabs/puppetdb.git","ssh_url":"git@github.com:puppetlabs/puppetdb.git","clone_url":"https://github.com/puppetlabs/puppetdb.git","svn_url":"https://github.com/puppetlabs/puppetdb","homepage":"http://docs.puppetlabs.com/puppetdb","size":17905,"stargazers_count":221,"watchers_count":221,"language":"Clojure","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":179,"mirror_url":null,"open_issues_count":9,"forks":179,"open_issues":9,"watchers":221,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/2380"},"html":{"href":"https://github.com/puppetlabs/puppetdb/pull/2380"},"issue":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/issues/2380"},"comments":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/issues/2380/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/2380/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/pulls/2380/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/puppetdb/statuses/ae204209b3af97ec08d04016b6788bdb19c73ba0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"wkalt"}}