{"action":"created","comment":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/comments/166107748","pull_request_review_id":94137545,"id":166107748,"diff_hunk":"@@ -124,7 +125,9 @@ def correct_unique?\n         end\n \n         def matched_index\n-          indexes.detect { |each| each.columns == @columns }\n+          indexes.detect do |each|\n+            each.columns == @columns || normalize_columns_to_string(each.columns) == @joined_columns","path":"lib/shoulda/matchers/active_record/have_db_index_matcher.rb","position":18,"original_position":18,"commit_id":"f81acb6e4f9006d6481a7d22ef7e27653f46dff9","original_commit_id":"f81acb6e4f9006d6481a7d22ef7e27653f46dff9","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Line is too long. [100/80]","created_at":"2018-02-05T20:51:11Z","updated_at":"2018-02-05T20:51:11Z","html_url":"https://github.com/thoughtbot/shoulda-matchers/pull/1080#discussion_r166107748","pull_request_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/1080","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/comments/166107748"},"html":{"href":"https://github.com/thoughtbot/shoulda-matchers/pull/1080#discussion_r166107748"},"pull_request":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/1080"}}},"pull_request":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/1080","id":166901465,"html_url":"https://github.com/thoughtbot/shoulda-matchers/pull/1080","diff_url":"https://github.com/thoughtbot/shoulda-matchers/pull/1080.diff","patch_url":"https://github.com/thoughtbot/shoulda-matchers/pull/1080.patch","issue_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/1080","number":1080,"state":"open","locked":false,"title":"[Help Needed] Add support for custom indices","user":{"login":"sirwolfgang","id":722517,"avatar_url":"https://avatars3.githubusercontent.com/u/722517?v=4","gravatar_id":"","url":"https://api.github.com/users/sirwolfgang","html_url":"https://github.com/sirwolfgang","followers_url":"https://api.github.com/users/sirwolfgang/followers","following_url":"https://api.github.com/users/sirwolfgang/following{/other_user}","gists_url":"https://api.github.com/users/sirwolfgang/gists{/gist_id}","starred_url":"https://api.github.com/users/sirwolfgang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirwolfgang/subscriptions","organizations_url":"https://api.github.com/users/sirwolfgang/orgs","repos_url":"https://api.github.com/users/sirwolfgang/repos","events_url":"https://api.github.com/users/sirwolfgang/events{/privacy}","received_events_url":"https://api.github.com/users/sirwolfgang/received_events","type":"User","site_admin":false},"body":"I am working on an issue with trying to validate custom created indices on postgres. I have worked out a patch for this issue, but am unable to create the same conditions in the unit specs on sqlite.\r\n\r\nMy project schema contains the following index, which was created through an execute statement:\r\n```sql\r\nt.index \"user_id, ((timezone('America/New_York'::text, timezone('UTC'::text, happened_at)))::date)\", name: \"index_table_on_user_per_day\", unique: true, using: :btree\r\n````\r\nWhen you look at the index the column is seen as the entire index.\r\n```sql\r\n[6] #<ActiveRecord::ConnectionAdapters::IndexDefinition:0x7ffc8e3a3f58\r\n        columns = \"user_id, ((timezone('America/New_York'::text, timezone('UTC'::text, happened_at)))::date)\",\r\n        comment = nil,\r\n        lengths = [],\r\n        name = \"index_table_on_user_per_day\",\r\n        orders = nil,\r\n        table = :table,\r\n        type = nil,\r\n        unique = true,\r\n        using = :btree,\r\n        where = nil\r\n    >,\r\n```\r\n\r\nThere are two inputs that I think should work in this case, the latter requires a better understanding of what is happening under the hood.\r\n```ruby\r\n# Intuitive \r\n  it { should have_db_index([:user_id, \"((timezone('America/New_York'::text, timezone('UTC'::text, happened_at)))::date)\"]).unique }\r\n\r\n# Not Intuitive\r\n  it { should have_db_index([\"user_id, ((timezone('America/New_York'::text, timezone('UTC'::text, happened_at)))::date)\"]).unique }\r\n```\r\n\r\nOne solution would be to do all the compares in `#matched_index` after joining the columns to a string, but I expect this would break a lot of people's specs since that would be the compare order dependent of the array. The other solution is to do a 2nd check for this case, using a joined version of the columns. While it would be order dependent in this one case, I don't think building out the possible permutations is reasonable, and trying to split definition would be error-prone(Unless you split both?).\r\n\r\nThe issue I ran into while working on this is that the unit tests run on sqlite and as such have a different reaction to trying to deserialize these indices.\r\n```ruby\r\ndb_connection.execute \"CREATE INDEX index_geocodings_on_geocodable_id_per_abs ON geocodings(geocodable_id, abs(geocodable_value));\"\r\n=> [#<struct ActiveRecord::ConnectionAdapters::IndexDefinition\r\n  table=:geocodings,\r\n  name=\"index_geocodings_on_geocodable_id_per_abs\",\r\n  unique=false,\r\n  columns=[\"geocodable_id\", nil],\r\n  lengths=nil,\r\n  orders=nil,\r\n  where=nil,\r\n  type=nil,\r\n  using=nil,\r\n  comment=nil>]\r\n```\r\n\r\nSo while my solution would work on postgres, I am not sure the correct way to move forward creating a PR based on sqlite.\r\n```ruby\r\ndef matched_index\r\n  raw_sql_columns = @columns.join(', ')\r\n\r\n  indexes.detect { |each| [@columns, raw_sql_columns].include?(each.columns) }\r\nend\r\n```","created_at":"2018-02-02T20:55:55Z","updated_at":"2018-02-05T20:51:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52dac33df608bc5f628fc9e6ac3b774e5ce89b66","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/1080/commits","review_comments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/1080/comments","review_comment_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/1080/comments","statuses_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/statuses/f81acb6e4f9006d6481a7d22ef7e27653f46dff9","head":{"label":"AquilaLoans:master","ref":"master","sha":"f81acb6e4f9006d6481a7d22ef7e27653f46dff9","user":{"login":"AquilaLoans","id":19155811,"avatar_url":"https://avatars1.githubusercontent.com/u/19155811?v=4","gravatar_id":"","url":"https://api.github.com/users/AquilaLoans","html_url":"https://github.com/AquilaLoans","followers_url":"https://api.github.com/users/AquilaLoans/followers","following_url":"https://api.github.com/users/AquilaLoans/following{/other_user}","gists_url":"https://api.github.com/users/AquilaLoans/gists{/gist_id}","starred_url":"https://api.github.com/users/AquilaLoans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AquilaLoans/subscriptions","organizations_url":"https://api.github.com/users/AquilaLoans/orgs","repos_url":"https://api.github.com/users/AquilaLoans/repos","events_url":"https://api.github.com/users/AquilaLoans/events{/privacy}","received_events_url":"https://api.github.com/users/AquilaLoans/received_events","type":"Organization","site_admin":false},"repo":{"id":120019796,"name":"shoulda-matchers","full_name":"AquilaLoans/shoulda-matchers","owner":{"login":"AquilaLoans","id":19155811,"avatar_url":"https://avatars1.githubusercontent.com/u/19155811?v=4","gravatar_id":"","url":"https://api.github.com/users/AquilaLoans","html_url":"https://github.com/AquilaLoans","followers_url":"https://api.github.com/users/AquilaLoans/followers","following_url":"https://api.github.com/users/AquilaLoans/following{/other_user}","gists_url":"https://api.github.com/users/AquilaLoans/gists{/gist_id}","starred_url":"https://api.github.com/users/AquilaLoans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AquilaLoans/subscriptions","organizations_url":"https://api.github.com/users/AquilaLoans/orgs","repos_url":"https://api.github.com/users/AquilaLoans/repos","events_url":"https://api.github.com/users/AquilaLoans/events{/privacy}","received_events_url":"https://api.github.com/users/AquilaLoans/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AquilaLoans/shoulda-matchers","description":"Collection of testing matchers extracted from Shoulda","fork":true,"url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers","forks_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/forks","keys_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/teams","hooks_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/hooks","issue_events_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/issues/events{/number}","events_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/events","assignees_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/assignees{/user}","branches_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/branches{/branch}","tags_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/tags","blobs_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/git/refs{/sha}","trees_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/statuses/{sha}","languages_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/languages","stargazers_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/stargazers","contributors_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/contributors","subscribers_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/subscribers","subscription_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/subscription","commits_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/commits{/sha}","git_commits_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/git/commits{/sha}","comments_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/comments{/number}","issue_comment_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/issues/comments{/number}","contents_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/contents/{+path}","compare_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/merges","archive_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/downloads","issues_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/issues{/number}","pulls_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/pulls{/number}","milestones_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/milestones{/number}","notifications_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/labels{/name}","releases_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/releases{/id}","deployments_url":"https://api.github.com/repos/AquilaLoans/shoulda-matchers/deployments","created_at":"2018-02-02T19:02:55Z","updated_at":"2018-02-02T19:02:58Z","pushed_at":"2018-02-05T20:51:02Z","git_url":"git://github.com/AquilaLoans/shoulda-matchers.git","ssh_url":"git@github.com:AquilaLoans/shoulda-matchers.git","clone_url":"https://github.com/AquilaLoans/shoulda-matchers.git","svn_url":"https://github.com/AquilaLoans/shoulda-matchers","homepage":"http://matchers.shoulda.io","size":13480,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"thoughtbot:master","ref":"master","sha":"cd96089a56b97cd11f7502826636895253eca27d","user":{"login":"thoughtbot","id":6183,"avatar_url":"https://avatars3.githubusercontent.com/u/6183?v=4","gravatar_id":"","url":"https://api.github.com/users/thoughtbot","html_url":"https://github.com/thoughtbot","followers_url":"https://api.github.com/users/thoughtbot/followers","following_url":"https://api.github.com/users/thoughtbot/following{/other_user}","gists_url":"https://api.github.com/users/thoughtbot/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtbot/subscriptions","organizations_url":"https://api.github.com/users/thoughtbot/orgs","repos_url":"https://api.github.com/users/thoughtbot/repos","events_url":"https://api.github.com/users/thoughtbot/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtbot/received_events","type":"Organization","site_admin":false},"repo":{"id":1172597,"name":"shoulda-matchers","full_name":"thoughtbot/shoulda-matchers","owner":{"login":"thoughtbot","id":6183,"avatar_url":"https://avatars3.githubusercontent.com/u/6183?v=4","gravatar_id":"","url":"https://api.github.com/users/thoughtbot","html_url":"https://github.com/thoughtbot","followers_url":"https://api.github.com/users/thoughtbot/followers","following_url":"https://api.github.com/users/thoughtbot/following{/other_user}","gists_url":"https://api.github.com/users/thoughtbot/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtbot/subscriptions","organizations_url":"https://api.github.com/users/thoughtbot/orgs","repos_url":"https://api.github.com/users/thoughtbot/repos","events_url":"https://api.github.com/users/thoughtbot/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thoughtbot/shoulda-matchers","description":"Collection of testing matchers extracted from Shoulda","fork":false,"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers","forks_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/forks","keys_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/teams","hooks_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/hooks","issue_events_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/events{/number}","events_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/events","assignees_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/assignees{/user}","branches_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/branches{/branch}","tags_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/tags","blobs_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/git/refs{/sha}","trees_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/statuses/{sha}","languages_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/languages","stargazers_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/stargazers","contributors_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/contributors","subscribers_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/subscribers","subscription_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/subscription","commits_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/commits{/sha}","git_commits_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/git/commits{/sha}","comments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/comments{/number}","issue_comment_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/comments{/number}","contents_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/contents/{+path}","compare_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/merges","archive_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/downloads","issues_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues{/number}","pulls_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls{/number}","milestones_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/milestones{/number}","notifications_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/labels{/name}","releases_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/releases{/id}","deployments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/deployments","created_at":"2010-12-15T22:41:52Z","updated_at":"2018-02-05T19:13:55Z","pushed_at":"2018-02-05T20:51:05Z","git_url":"git://github.com/thoughtbot/shoulda-matchers.git","ssh_url":"git@github.com:thoughtbot/shoulda-matchers.git","clone_url":"https://github.com/thoughtbot/shoulda-matchers.git","svn_url":"https://github.com/thoughtbot/shoulda-matchers","homepage":"http://matchers.shoulda.io","size":13479,"stargazers_count":2207,"watchers_count":2207,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":666,"mirror_url":null,"archived":false,"open_issues_count":123,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":666,"open_issues":123,"watchers":2207,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/1080"},"html":{"href":"https://github.com/thoughtbot/shoulda-matchers/pull/1080"},"issue":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/1080"},"comments":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/1080/comments"},"review_comments":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/1080/comments"},"review_comment":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/pulls/1080/commits"},"statuses":{"href":"https://api.github.com/repos/thoughtbot/shoulda-matchers/statuses/f81acb6e4f9006d6481a7d22ef7e27653f46dff9"}},"author_association":"NONE"}}
{"actor":{"display_login":"houndci-bot"}}