{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/56044021","id":56044021,"diff_hunk":"@@ -874,4 +874,46 @@ def vacuum_analyze_table(table)\n   def vacuum_full_analyze_table(table)\n     execute(\"VACUUM FULL ANALYZE #{quote_table_name(table)}\")\n   end\n+\n+  def self.parse_dsn(dsn)\n+    scanner = StringScanner.new(dsn)\n+\n+    dsn_hash = {}\n+\n+    until scanner.eos?\n+      # get the key by matching up to and including the (optionally) white space bordered '='\n+      key = scanner.scan_until(/\\s?=\\s?/)\n+      key = key[0..-(scanner.matched_size + 1)]\n+\n+      dsn_hash[key.to_sym] = get_dsn_value(scanner)\n+    end\n+\n+    dsn_hash\n+  end\n+\n+  def self.get_dsn_value(scanner)\n+    # if we are a quoted value\n+    if scanner.peek(1) == \"'\"\n+      # get the first quote and the string that ends with a quote not preceded by a backslash\n+      value = scanner.getch + scanner.scan_until(/(?<!\\\\)'\\s*/).strip\n+    # if there is more whitespace\n+    elsif scanner.exist?(/\\s+/)\n+      value = scanner.scan_until(/\\s+/).strip\n+    else\n+      value = scanner.rest\n+      scanner.terminate\n+    end\n+\n+    # strip the leading and trailing quotes if they exist\n+    #   we only strip the trailing space if we strip a leading\n+    #   space because the trailing space could be escaped with a \\,\n+    #   but a trailing space must exist if we stripped a leading space\n+    value.gsub!(/'\\z/, \"\") if value.gsub!(/\\A'/, \"\")","path":"lib/extensions/ar_adapter/ar_dba/postgresql.rb","position":38,"original_position":38,"commit_id":"00127870bfea898ea5ab358638d6bcc853a82ab6","original_commit_id":"00127870bfea898ea5ab358638d6bcc853a82ab6","user":{"login":"Fryguy","id":52120,"avatar_url":"https://avatars.githubusercontent.com/u/52120?v=3","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"body":"I think prefer `key = key[1..-2] if key.start_with?(\"'\") && key.end_with?(\"'\")`","created_at":"2016-03-14T17:48:54Z","updated_at":"2016-03-14T17:48:54Z","html_url":"https://github.com/ManageIQ/manageiq/pull/7250#discussion_r56044021","pull_request_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7250","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/56044021"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/7250#discussion_r56044021"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7250"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7250","id":62608519,"html_url":"https://github.com/ManageIQ/manageiq/pull/7250","diff_url":"https://github.com/ManageIQ/manageiq/pull/7250.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/7250.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/7250","number":7250,"state":"open","locked":false,"title":"Add a dsn to hash parser to the ar_dba extension","user":{"login":"carbonin","id":12697904,"avatar_url":"https://avatars.githubusercontent.com/u/12697904?v=3","gravatar_id":"","url":"https://api.github.com/users/carbonin","html_url":"https://github.com/carbonin","followers_url":"https://api.github.com/users/carbonin/followers","following_url":"https://api.github.com/users/carbonin/following{/other_user}","gists_url":"https://api.github.com/users/carbonin/gists{/gist_id}","starred_url":"https://api.github.com/users/carbonin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carbonin/subscriptions","organizations_url":"https://api.github.com/users/carbonin/orgs","repos_url":"https://api.github.com/users/carbonin/repos","events_url":"https://api.github.com/users/carbonin/events{/privacy}","received_events_url":"https://api.github.com/users/carbonin/received_events","type":"User","site_admin":false},"body":"There is not currently a good way to get a connection params hash from a postgres dsn string without creating a new connection using those values.\r\n\r\nThis provides us with one initially to be used when reading connection strings from the database while dealing with pglogical.\r\n\r\n@Fryguy ","created_at":"2016-03-11T21:56:43Z","updated_at":"2016-03-14T17:48:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e0778e26032f71bfd69e56fbdd1a95733869941","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7250/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7250/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/7250/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/00127870bfea898ea5ab358638d6bcc853a82ab6","head":{"label":"carbonin:add_dsn_parser_to_ar_dba","ref":"add_dsn_parser_to_ar_dba","sha":"00127870bfea898ea5ab358638d6bcc853a82ab6","user":{"login":"carbonin","id":12697904,"avatar_url":"https://avatars.githubusercontent.com/u/12697904?v=3","gravatar_id":"","url":"https://api.github.com/users/carbonin","html_url":"https://github.com/carbonin","followers_url":"https://api.github.com/users/carbonin/followers","following_url":"https://api.github.com/users/carbonin/following{/other_user}","gists_url":"https://api.github.com/users/carbonin/gists{/gist_id}","starred_url":"https://api.github.com/users/carbonin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carbonin/subscriptions","organizations_url":"https://api.github.com/users/carbonin/orgs","repos_url":"https://api.github.com/users/carbonin/repos","events_url":"https://api.github.com/users/carbonin/events{/privacy}","received_events_url":"https://api.github.com/users/carbonin/received_events","type":"User","site_admin":false},"repo":{"id":36686944,"name":"manageiq","full_name":"carbonin/manageiq","owner":{"login":"carbonin","id":12697904,"avatar_url":"https://avatars.githubusercontent.com/u/12697904?v=3","gravatar_id":"","url":"https://api.github.com/users/carbonin","html_url":"https://github.com/carbonin","followers_url":"https://api.github.com/users/carbonin/followers","following_url":"https://api.github.com/users/carbonin/following{/other_user}","gists_url":"https://api.github.com/users/carbonin/gists{/gist_id}","starred_url":"https://api.github.com/users/carbonin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carbonin/subscriptions","organizations_url":"https://api.github.com/users/carbonin/orgs","repos_url":"https://api.github.com/users/carbonin/repos","events_url":"https://api.github.com/users/carbonin/events{/privacy}","received_events_url":"https://api.github.com/users/carbonin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/carbonin/manageiq","description":"ManageIQ Cloud Management Platform","fork":true,"url":"https://api.github.com/repos/carbonin/manageiq","forks_url":"https://api.github.com/repos/carbonin/manageiq/forks","keys_url":"https://api.github.com/repos/carbonin/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/carbonin/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/carbonin/manageiq/teams","hooks_url":"https://api.github.com/repos/carbonin/manageiq/hooks","issue_events_url":"https://api.github.com/repos/carbonin/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/carbonin/manageiq/events","assignees_url":"https://api.github.com/repos/carbonin/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/carbonin/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/carbonin/manageiq/tags","blobs_url":"https://api.github.com/repos/carbonin/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/carbonin/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/carbonin/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/carbonin/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/carbonin/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/carbonin/manageiq/languages","stargazers_url":"https://api.github.com/repos/carbonin/manageiq/stargazers","contributors_url":"https://api.github.com/repos/carbonin/manageiq/contributors","subscribers_url":"https://api.github.com/repos/carbonin/manageiq/subscribers","subscription_url":"https://api.github.com/repos/carbonin/manageiq/subscription","commits_url":"https://api.github.com/repos/carbonin/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/carbonin/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/carbonin/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/carbonin/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/carbonin/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/carbonin/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/carbonin/manageiq/merges","archive_url":"https://api.github.com/repos/carbonin/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/carbonin/manageiq/downloads","issues_url":"https://api.github.com/repos/carbonin/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/carbonin/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/carbonin/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/carbonin/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/carbonin/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/carbonin/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/carbonin/manageiq/deployments","created_at":"2015-06-01T20:29:47Z","updated_at":"2015-06-01T20:30:04Z","pushed_at":"2016-03-11T22:08:07Z","git_url":"git://github.com/carbonin/manageiq.git","ssh_url":"git@github.com:carbonin/manageiq.git","clone_url":"https://github.com/carbonin/manageiq.git","svn_url":"https://github.com/carbonin/manageiq","homepage":"manageiq.org","size":110368,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"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":"ManageIQ:master","ref":"master","sha":"3e0258231656b69159d57b9b4cae4fa81bbbe2c9","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":20789757,"name":"manageiq","full_name":"ManageIQ/manageiq","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/manageiq","description":"ManageIQ Cloud Management Platform","fork":false,"url":"https://api.github.com/repos/ManageIQ/manageiq","forks_url":"https://api.github.com/repos/ManageIQ/manageiq/forks","keys_url":"https://api.github.com/repos/ManageIQ/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/manageiq/teams","hooks_url":"https://api.github.com/repos/ManageIQ/manageiq/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/manageiq/events","assignees_url":"https://api.github.com/repos/ManageIQ/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/manageiq/tags","blobs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/manageiq/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/manageiq/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/manageiq/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/manageiq/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/manageiq/subscription","commits_url":"https://api.github.com/repos/ManageIQ/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/manageiq/merges","archive_url":"https://api.github.com/repos/ManageIQ/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/manageiq/downloads","issues_url":"https://api.github.com/repos/ManageIQ/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/manageiq/deployments","created_at":"2014-06-13T02:31:26Z","updated_at":"2016-03-14T11:14:57Z","pushed_at":"2016-03-14T17:46:58Z","git_url":"git://github.com/ManageIQ/manageiq.git","ssh_url":"git@github.com:ManageIQ/manageiq.git","clone_url":"https://github.com/ManageIQ/manageiq.git","svn_url":"https://github.com/ManageIQ/manageiq","homepage":"manageiq.org","size":146979,"stargazers_count":231,"watchers_count":231,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":255,"mirror_url":null,"open_issues_count":608,"forks":255,"open_issues":608,"watchers":231,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7250"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/7250"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/7250"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/7250/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7250/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7250/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq/statuses/00127870bfea898ea5ab358638d6bcc853a82ab6"}}}}