{"action":"closed","issue":{"url":"https://api.github.com/repos/covermymeds/sql_footprint/issues/16","repository_url":"https://api.github.com/repos/covermymeds/sql_footprint","labels_url":"https://api.github.com/repos/covermymeds/sql_footprint/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/covermymeds/sql_footprint/issues/16/comments","events_url":"https://api.github.com/repos/covermymeds/sql_footprint/issues/16/events","html_url":"https://github.com/covermymeds/sql_footprint/issues/16","id":147747970,"number":16,"title":"Adding uniqueness constraint results in non-deduped entries","user":{"login":"ryanzbone","id":2286261,"avatar_url":"https://avatars.githubusercontent.com/u/2286261?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanzbone","html_url":"https://github.com/ryanzbone","followers_url":"https://api.github.com/users/ryanzbone/followers","following_url":"https://api.github.com/users/ryanzbone/following{/other_user}","gists_url":"https://api.github.com/users/ryanzbone/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanzbone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanzbone/subscriptions","organizations_url":"https://api.github.com/users/ryanzbone/orgs","repos_url":"https://api.github.com/users/ryanzbone/repos","events_url":"https://api.github.com/users/ryanzbone/events{/privacy}","received_events_url":"https://api.github.com/users/ryanzbone/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-12T13:15:45Z","updated_at":"2016-04-15T13:19:39Z","closed_at":"2016-04-15T13:19:39Z","body":"Added the following validation to our `QueueItem` model:\r\n```ruby\r\nvalidates :incoming_fax_id, uniqueness: true\r\n```\r\nresulted in\r\n```sql\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 1) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 11) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 12) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 13) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 14) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 15) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 16) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 17) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 18) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 19) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 22) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 38) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 39) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 4) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 42) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 43) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 44) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 5) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 50) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 51) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 53) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 54) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 6) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 66) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 67) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 68) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 69) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 7) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 70) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 71) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" = number-redacted AND \"queue_items\".\"id\" != 84) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 1) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 15) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 16) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 17) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 18) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 2) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 28) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 29) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 3) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 30) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 31) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 32) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 33) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 34) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 35) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 36) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 4) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 5) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 68) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 69) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 70) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 71) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 72) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 73) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 74) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 75) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 76) LIMIT 1\r\n+SELECT  1 AS one FROM \"queue_items\" WHERE (\"queue_items\".\"incoming_fax_id\" IS NULL AND \"queue_items\".\"id\" != 83) LIMIT 1\r\n```\r\n\r\nOld and new footprints: [footprints.zip](https://github.com/covermymeds/sql_footprint/files/215053/footprints.zip)\r\n"}}