{"action":"created","comment":{"url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/comments/152580253","pull_request_review_id":78458194,"id":152580253,"diff_hunk":"@@ -0,0 +1,95 @@\n+package com.github.embeditcz.dbadvisor.core.internal.analyzer.oracle;\n+\n+import com.github.embeditcz.dbadvisor.core.analyzer.DatabaseContext;\n+import com.github.embeditcz.dbadvisor.core.internal.analyzer.AbstractDatabaseAnalyzer;\n+import com.github.embeditcz.dbadvisor.core.issue.Issue;\n+import org.springframework.jdbc.core.JdbcTemplate;\n+import org.springframework.stereotype.Component;\n+\n+import javax.sql.DataSource;\n+import java.sql.SQLException;\n+import java.util.List;\n+import java.util.Map;\n+\n+import static java.lang.String.format;\n+\n+@Component\n+public class ForeignKeyAnalayzer extends AbstractDatabaseAnalyzer {\n+\n+    private static String FOREIGN_KEY_QUERY = \"WITH constr AS (\" +\n+        \"SELECT c.owner, \" +\n+            \"c.table_name, \" +\n+            \"c.constraint_name, \" +\n+            \"listagg(col.column_name, ', ') within group (ORDER BY col.column_name) column_list_alphabetic, \" +\n+            \"listagg(col.column_name, ', ') within group (ORDER BY col.position) column_list \" +\n+        \"FROM all_constraints c \" +\n+        \"JOIN all_cons_columns col ON ( col.owner = c.owner AND col.constraint_name = c.constraint_name AND col.table_name = c.table_name ) \" +\n+        \"WHERE c.constraint_type = 'R' \" +\n+            \"AND c.owner = ? \" +\n+        \"GROUP BY c.owner, c.table_name, c.constraint_name), \" +\n+        \"idx AS (\" +\n+        \"SELECT table_owner, table_name, \" +\n+            \"listagg(column_name, ', ') within group (ORDER BY column_name) column_list_alphabetic, \" +\n+            \"listagg(column_name, ', ') within group (ORDER BY column_position) column_list \" +\n+        \"FROM all_ind_columns \" +\n+        \"WHERE table_owner = ? \" +\n+        \"GROUP BY table_owner, table_name, index_owner, index_name) \" +\n+        \"SELECT constr.owner, constr.table_name, constr.constraint_name, constr.column_list \" +\n+        \"FROM constr \" +\n+        \"WHERE NOT EXISTS ( \" +\n+            \"SELECT 1 \" +\n+            \"FROM idx \" +\n+            \"WHERE constr.owner = idx.table_owner \" +\n+                \"AND constr.table_name = idx.table_name \" +\n+                \"AND ( idx.column_list_alphabetic = constr.column_list_alphabetic \" +\n+                    \"OR instr(idx.column_list,constr.column_list) = 1 ))\";\n+\n+    private final ForeignKeyProperties properties;\n+\n+    ForeignKeyAnalayzer(ForeignKeyProperties properties) {\n+        super(properties::isEnabled);\n+        this.properties = properties;\n+    }\n+\n+    @Override\n+    protected String getName() {\n+        return \"Foreign key index\";\n+    }\n+\n+    @Override\n+    protected void analyzeImpl(DatabaseContext ctx) {\n+        JdbcTemplate jdbcTemplate = new JdbcTemplate(ctx.getDataSource());\n+        String schemaName = resolveSchemaName(ctx.getDataSource());\n+        List<Map<String, Object>> foreignKeys = jdbcTemplate.queryForList(FOREIGN_KEY_QUERY, schemaName, schemaName);\n+        if (foreignKeys.size() > 0) {\n+            Issue issue = issueBuilder.builder()\n+                .type(getName())\n+                .weight(foreignKeys.size())\n+                .query(FOREIGN_KEY_QUERY)","path":"dbadvisor-core/src/main/java/com/github/embeditcz/dbadvisor/core/internal/analyzer/oracle/ForeignKeyAnalayzer.java","position":68,"original_position":68,"commit_id":"933c177bf2089dee8fa8d337b376e1a61745b478","original_commit_id":"933c177bf2089dee8fa8d337b376e1a61745b478","user":{"login":"thradec","id":1357423,"avatar_url":"https://avatars2.githubusercontent.com/u/1357423?v=4","gravatar_id":"","url":"https://api.github.com/users/thradec","html_url":"https://github.com/thradec","followers_url":"https://api.github.com/users/thradec/followers","following_url":"https://api.github.com/users/thradec/following{/other_user}","gists_url":"https://api.github.com/users/thradec/gists{/gist_id}","starred_url":"https://api.github.com/users/thradec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thradec/subscriptions","organizations_url":"https://api.github.com/users/thradec/orgs","repos_url":"https://api.github.com/users/thradec/repos","events_url":"https://api.github.com/users/thradec/events{/privacy}","received_events_url":"https://api.github.com/users/thradec/received_events","type":"User","site_admin":false},"body":"as we spoke on monday, there is a theoretical issue with discarding issues, which have the same query and lower weight\r\n\r\none posible solution is to use null here and just fix the NPE in findIssueWithIdenticalQuery (which should return null, when the query is null) \r\n\r\nwdyt?","created_at":"2017-11-22T14:29:30Z","updated_at":"2017-11-22T14:29:42Z","html_url":"https://github.com/EmbedITCZ/dbadvisor/pull/33#discussion_r152580253","pull_request_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/33","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/comments/152580253"},"html":{"href":"https://github.com/EmbedITCZ/dbadvisor/pull/33#discussion_r152580253"},"pull_request":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/33","id":153464341,"html_url":"https://github.com/EmbedITCZ/dbadvisor/pull/33","diff_url":"https://github.com/EmbedITCZ/dbadvisor/pull/33.diff","patch_url":"https://github.com/EmbedITCZ/dbadvisor/pull/33.patch","issue_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/issues/33","number":33,"state":"open","locked":false,"title":"#24 Resolved support for analyzers which are running only once","user":{"login":"mbocek","id":1130294,"avatar_url":"https://avatars1.githubusercontent.com/u/1130294?v=4","gravatar_id":"","url":"https://api.github.com/users/mbocek","html_url":"https://github.com/mbocek","followers_url":"https://api.github.com/users/mbocek/followers","following_url":"https://api.github.com/users/mbocek/following{/other_user}","gists_url":"https://api.github.com/users/mbocek/gists{/gist_id}","starred_url":"https://api.github.com/users/mbocek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbocek/subscriptions","organizations_url":"https://api.github.com/users/mbocek/orgs","repos_url":"https://api.github.com/users/mbocek/repos","events_url":"https://api.github.com/users/mbocek/events{/privacy}","received_events_url":"https://api.github.com/users/mbocek/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-11-18T19:31:31Z","updated_at":"2017-11-22T14:29:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cfbba315f9b2da7afc5424751e3110d845ed8bda","assignee":{"login":"thradec","id":1357423,"avatar_url":"https://avatars2.githubusercontent.com/u/1357423?v=4","gravatar_id":"","url":"https://api.github.com/users/thradec","html_url":"https://github.com/thradec","followers_url":"https://api.github.com/users/thradec/followers","following_url":"https://api.github.com/users/thradec/following{/other_user}","gists_url":"https://api.github.com/users/thradec/gists{/gist_id}","starred_url":"https://api.github.com/users/thradec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thradec/subscriptions","organizations_url":"https://api.github.com/users/thradec/orgs","repos_url":"https://api.github.com/users/thradec/repos","events_url":"https://api.github.com/users/thradec/events{/privacy}","received_events_url":"https://api.github.com/users/thradec/received_events","type":"User","site_admin":false},"assignees":[{"login":"thradec","id":1357423,"avatar_url":"https://avatars2.githubusercontent.com/u/1357423?v=4","gravatar_id":"","url":"https://api.github.com/users/thradec","html_url":"https://github.com/thradec","followers_url":"https://api.github.com/users/thradec/followers","following_url":"https://api.github.com/users/thradec/following{/other_user}","gists_url":"https://api.github.com/users/thradec/gists{/gist_id}","starred_url":"https://api.github.com/users/thradec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thradec/subscriptions","organizations_url":"https://api.github.com/users/thradec/orgs","repos_url":"https://api.github.com/users/thradec/repos","events_url":"https://api.github.com/users/thradec/events{/privacy}","received_events_url":"https://api.github.com/users/thradec/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/33/commits","review_comments_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/33/comments","review_comment_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/issues/33/comments","statuses_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/statuses/933c177bf2089dee8fa8d337b376e1a61745b478","head":{"label":"mbocek:dbadvisor-24","ref":"dbadvisor-24","sha":"933c177bf2089dee8fa8d337b376e1a61745b478","user":{"login":"mbocek","id":1130294,"avatar_url":"https://avatars1.githubusercontent.com/u/1130294?v=4","gravatar_id":"","url":"https://api.github.com/users/mbocek","html_url":"https://github.com/mbocek","followers_url":"https://api.github.com/users/mbocek/followers","following_url":"https://api.github.com/users/mbocek/following{/other_user}","gists_url":"https://api.github.com/users/mbocek/gists{/gist_id}","starred_url":"https://api.github.com/users/mbocek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbocek/subscriptions","organizations_url":"https://api.github.com/users/mbocek/orgs","repos_url":"https://api.github.com/users/mbocek/repos","events_url":"https://api.github.com/users/mbocek/events{/privacy}","received_events_url":"https://api.github.com/users/mbocek/received_events","type":"User","site_admin":false},"repo":{"id":109527355,"name":"dbadvisor","full_name":"mbocek/dbadvisor","owner":{"login":"mbocek","id":1130294,"avatar_url":"https://avatars1.githubusercontent.com/u/1130294?v=4","gravatar_id":"","url":"https://api.github.com/users/mbocek","html_url":"https://github.com/mbocek","followers_url":"https://api.github.com/users/mbocek/followers","following_url":"https://api.github.com/users/mbocek/following{/other_user}","gists_url":"https://api.github.com/users/mbocek/gists{/gist_id}","starred_url":"https://api.github.com/users/mbocek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbocek/subscriptions","organizations_url":"https://api.github.com/users/mbocek/orgs","repos_url":"https://api.github.com/users/mbocek/repos","events_url":"https://api.github.com/users/mbocek/events{/privacy}","received_events_url":"https://api.github.com/users/mbocek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mbocek/dbadvisor","description":"Clever tool for pointing out potential issues between java application and database.​","fork":true,"url":"https://api.github.com/repos/mbocek/dbadvisor","forks_url":"https://api.github.com/repos/mbocek/dbadvisor/forks","keys_url":"https://api.github.com/repos/mbocek/dbadvisor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mbocek/dbadvisor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mbocek/dbadvisor/teams","hooks_url":"https://api.github.com/repos/mbocek/dbadvisor/hooks","issue_events_url":"https://api.github.com/repos/mbocek/dbadvisor/issues/events{/number}","events_url":"https://api.github.com/repos/mbocek/dbadvisor/events","assignees_url":"https://api.github.com/repos/mbocek/dbadvisor/assignees{/user}","branches_url":"https://api.github.com/repos/mbocek/dbadvisor/branches{/branch}","tags_url":"https://api.github.com/repos/mbocek/dbadvisor/tags","blobs_url":"https://api.github.com/repos/mbocek/dbadvisor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mbocek/dbadvisor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mbocek/dbadvisor/git/refs{/sha}","trees_url":"https://api.github.com/repos/mbocek/dbadvisor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mbocek/dbadvisor/statuses/{sha}","languages_url":"https://api.github.com/repos/mbocek/dbadvisor/languages","stargazers_url":"https://api.github.com/repos/mbocek/dbadvisor/stargazers","contributors_url":"https://api.github.com/repos/mbocek/dbadvisor/contributors","subscribers_url":"https://api.github.com/repos/mbocek/dbadvisor/subscribers","subscription_url":"https://api.github.com/repos/mbocek/dbadvisor/subscription","commits_url":"https://api.github.com/repos/mbocek/dbadvisor/commits{/sha}","git_commits_url":"https://api.github.com/repos/mbocek/dbadvisor/git/commits{/sha}","comments_url":"https://api.github.com/repos/mbocek/dbadvisor/comments{/number}","issue_comment_url":"https://api.github.com/repos/mbocek/dbadvisor/issues/comments{/number}","contents_url":"https://api.github.com/repos/mbocek/dbadvisor/contents/{+path}","compare_url":"https://api.github.com/repos/mbocek/dbadvisor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mbocek/dbadvisor/merges","archive_url":"https://api.github.com/repos/mbocek/dbadvisor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mbocek/dbadvisor/downloads","issues_url":"https://api.github.com/repos/mbocek/dbadvisor/issues{/number}","pulls_url":"https://api.github.com/repos/mbocek/dbadvisor/pulls{/number}","milestones_url":"https://api.github.com/repos/mbocek/dbadvisor/milestones{/number}","notifications_url":"https://api.github.com/repos/mbocek/dbadvisor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mbocek/dbadvisor/labels{/name}","releases_url":"https://api.github.com/repos/mbocek/dbadvisor/releases{/id}","deployments_url":"https://api.github.com/repos/mbocek/dbadvisor/deployments","created_at":"2017-11-04T20:19:53Z","updated_at":"2017-11-04T20:19:55Z","pushed_at":"2017-11-21T22:51:40Z","git_url":"git://github.com/mbocek/dbadvisor.git","ssh_url":"git@github.com:mbocek/dbadvisor.git","clone_url":"https://github.com/mbocek/dbadvisor.git","svn_url":"https://github.com/mbocek/dbadvisor","homepage":"","size":277,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"EmbedITCZ:master","ref":"master","sha":"80f0752fe8161e8399cc05c486898dc21dd2e0e2","user":{"login":"EmbedITCZ","id":26916275,"avatar_url":"https://avatars3.githubusercontent.com/u/26916275?v=4","gravatar_id":"","url":"https://api.github.com/users/EmbedITCZ","html_url":"https://github.com/EmbedITCZ","followers_url":"https://api.github.com/users/EmbedITCZ/followers","following_url":"https://api.github.com/users/EmbedITCZ/following{/other_user}","gists_url":"https://api.github.com/users/EmbedITCZ/gists{/gist_id}","starred_url":"https://api.github.com/users/EmbedITCZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EmbedITCZ/subscriptions","organizations_url":"https://api.github.com/users/EmbedITCZ/orgs","repos_url":"https://api.github.com/users/EmbedITCZ/repos","events_url":"https://api.github.com/users/EmbedITCZ/events{/privacy}","received_events_url":"https://api.github.com/users/EmbedITCZ/received_events","type":"Organization","site_admin":false},"repo":{"id":109368326,"name":"dbadvisor","full_name":"EmbedITCZ/dbadvisor","owner":{"login":"EmbedITCZ","id":26916275,"avatar_url":"https://avatars3.githubusercontent.com/u/26916275?v=4","gravatar_id":"","url":"https://api.github.com/users/EmbedITCZ","html_url":"https://github.com/EmbedITCZ","followers_url":"https://api.github.com/users/EmbedITCZ/followers","following_url":"https://api.github.com/users/EmbedITCZ/following{/other_user}","gists_url":"https://api.github.com/users/EmbedITCZ/gists{/gist_id}","starred_url":"https://api.github.com/users/EmbedITCZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EmbedITCZ/subscriptions","organizations_url":"https://api.github.com/users/EmbedITCZ/orgs","repos_url":"https://api.github.com/users/EmbedITCZ/repos","events_url":"https://api.github.com/users/EmbedITCZ/events{/privacy}","received_events_url":"https://api.github.com/users/EmbedITCZ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/EmbedITCZ/dbadvisor","description":"Clever tool for pointing out potential issues between java application and database.​","fork":false,"url":"https://api.github.com/repos/EmbedITCZ/dbadvisor","forks_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/forks","keys_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/teams","hooks_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/hooks","issue_events_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/issues/events{/number}","events_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/events","assignees_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/assignees{/user}","branches_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/branches{/branch}","tags_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/tags","blobs_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/git/refs{/sha}","trees_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/statuses/{sha}","languages_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/languages","stargazers_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/stargazers","contributors_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/contributors","subscribers_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/subscribers","subscription_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/subscription","commits_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/commits{/sha}","git_commits_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/git/commits{/sha}","comments_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/comments{/number}","issue_comment_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/issues/comments{/number}","contents_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/contents/{+path}","compare_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/merges","archive_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/downloads","issues_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/issues{/number}","pulls_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls{/number}","milestones_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/milestones{/number}","notifications_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/labels{/name}","releases_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/releases{/id}","deployments_url":"https://api.github.com/repos/EmbedITCZ/dbadvisor/deployments","created_at":"2017-11-03T07:58:53Z","updated_at":"2017-11-11T19:22:01Z","pushed_at":"2017-11-22T06:20:11Z","git_url":"git://github.com/EmbedITCZ/dbadvisor.git","ssh_url":"git@github.com:EmbedITCZ/dbadvisor.git","clone_url":"https://github.com/EmbedITCZ/dbadvisor.git","svn_url":"https://github.com/EmbedITCZ/dbadvisor","homepage":"","size":263,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":8,"forks":2,"open_issues":8,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/33"},"html":{"href":"https://github.com/EmbedITCZ/dbadvisor/pull/33"},"issue":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/issues/33"},"comments":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/EmbedITCZ/dbadvisor/statuses/933c177bf2089dee8fa8d337b376e1a61745b478"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"thradec"}}