{"action":"created","comment":{"url":"https://api.github.com/repos/swanandp/acts_as_list/pulls/comments/94115150","pull_request_review_id":14645185,"id":94115150,"diff_hunk":"@@ -317,32 +317,53 @@ def increment_positions_on_all_items\n         # Reorders intermediate items to support moving an item from old_position to new_position.\n         def shuffle_positions_on_intermediate_items(old_position, new_position, avoid_id = nil)\n           return if old_position == new_position\n-          scope = acts_as_list_list\n+          scope = acts_as_list_list.select(:id)\n \n           if avoid_id\n             scope = scope.where(\"#{quoted_table_name}.#{self.class.primary_key} != ?\", self.class.connection.quote(avoid_id))\n           end\n \n+          # unique constraint prevents regular increment_all and forces to do increments one by one\n+          # http://stackoverflow.com/questions/7703196/sqlite-increment-unique-integer-field\n+          # both SQLite and PostgreSQL (and most probably MySQL too) has same issue\n+          update_one_by_one = acts_as_list_list.connection.index_exists?(acts_as_list_list.table_name, position_column, unique: true)","path":"lib/acts_as_list/active_record/acts/list.rb","position":14,"original_position":14,"commit_id":"83cdf798a3ec21410c8263cf867b0206ce3ca905","original_commit_id":"83cdf798a3ec21410c8263cf867b0206ce3ca905","user":{"login":"brendon","id":81871,"avatar_url":"https://avatars.githubusercontent.com/u/81871?v=3","gravatar_id":"","url":"https://api.github.com/users/brendon","html_url":"https://github.com/brendon","followers_url":"https://api.github.com/users/brendon/followers","following_url":"https://api.github.com/users/brendon/following{/other_user}","gists_url":"https://api.github.com/users/brendon/gists{/gist_id}","starred_url":"https://api.github.com/users/brendon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendon/subscriptions","organizations_url":"https://api.github.com/users/brendon/orgs","repos_url":"https://api.github.com/users/brendon/repos","events_url":"https://api.github.com/users/brendon/events{/privacy}","received_events_url":"https://api.github.com/users/brendon/received_events","type":"User","site_admin":false},"body":"I'm thinking this should be defined more globally (even though it's only used here) as it feels more like a configuration option. What do you think? You could set it at initialisation.","created_at":"2016-12-29T09:14:26Z","updated_at":"2016-12-29T09:17:56Z","html_url":"https://github.com/swanandp/acts_as_list/pull/246#discussion_r94115150","pull_request_url":"https://api.github.com/repos/swanandp/acts_as_list/pulls/246","_links":{"self":{"href":"https://api.github.com/repos/swanandp/acts_as_list/pulls/comments/94115150"},"html":{"href":"https://github.com/swanandp/acts_as_list/pull/246#discussion_r94115150"},"pull_request":{"href":"https://api.github.com/repos/swanandp/acts_as_list/pulls/246"}}},"pull_request":{"url":"https://api.github.com/repos/swanandp/acts_as_list/pulls/246","id":99176709,"html_url":"https://github.com/swanandp/acts_as_list/pull/246","diff_url":"https://github.com/swanandp/acts_as_list/pull/246.diff","patch_url":"https://github.com/swanandp/acts_as_list/pull/246.patch","issue_url":"https://api.github.com/repos/swanandp/acts_as_list/issues/246","number":246,"state":"open","locked":false,"title":"insert_at respects unique not null check (>= 0) db constraints","user":{"login":"zharikovpro","id":2053886,"avatar_url":"https://avatars.githubusercontent.com/u/2053886?v=3","gravatar_id":"","url":"https://api.github.com/users/zharikovpro","html_url":"https://github.com/zharikovpro","followers_url":"https://api.github.com/users/zharikovpro/followers","following_url":"https://api.github.com/users/zharikovpro/following{/other_user}","gists_url":"https://api.github.com/users/zharikovpro/gists{/gist_id}","starred_url":"https://api.github.com/users/zharikovpro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zharikovpro/subscriptions","organizations_url":"https://api.github.com/users/zharikovpro/orgs","repos_url":"https://api.github.com/users/zharikovpro/repos","events_url":"https://api.github.com/users/zharikovpro/events{/privacy}","received_events_url":"https://api.github.com/users/zharikovpro/received_events","type":"User","site_admin":false},"body":"Following [this discussion](https://github.com/swanandp/acts_as_list/pull/135).\r\n\r\nProposal to resolve db constraints issues. It targets insert_at cause it's often used by UI clients. Great demo of this is [ActiveAdmin Reorderable gem](https://github.com/vigetlabs/activeadmin_reorderable).","created_at":"2016-12-22T22:02:03Z","updated_at":"2016-12-29T09:17:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"77daca923ffa1e71b89868b3f1f9cc8a498c5e23","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/swanandp/acts_as_list/pulls/246/commits","review_comments_url":"https://api.github.com/repos/swanandp/acts_as_list/pulls/246/comments","review_comment_url":"https://api.github.com/repos/swanandp/acts_as_list/pulls/comments{/number}","comments_url":"https://api.github.com/repos/swanandp/acts_as_list/issues/246/comments","statuses_url":"https://api.github.com/repos/swanandp/acts_as_list/statuses/83cdf798a3ec21410c8263cf867b0206ce3ca905","head":{"label":"zharikovpro:unique_not_null","ref":"unique_not_null","sha":"83cdf798a3ec21410c8263cf867b0206ce3ca905","user":{"login":"zharikovpro","id":2053886,"avatar_url":"https://avatars.githubusercontent.com/u/2053886?v=3","gravatar_id":"","url":"https://api.github.com/users/zharikovpro","html_url":"https://github.com/zharikovpro","followers_url":"https://api.github.com/users/zharikovpro/followers","following_url":"https://api.github.com/users/zharikovpro/following{/other_user}","gists_url":"https://api.github.com/users/zharikovpro/gists{/gist_id}","starred_url":"https://api.github.com/users/zharikovpro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zharikovpro/subscriptions","organizations_url":"https://api.github.com/users/zharikovpro/orgs","repos_url":"https://api.github.com/users/zharikovpro/repos","events_url":"https://api.github.com/users/zharikovpro/events{/privacy}","received_events_url":"https://api.github.com/users/zharikovpro/received_events","type":"User","site_admin":false},"repo":{"id":77172838,"name":"acts_as_list","full_name":"zharikovpro/acts_as_list","owner":{"login":"zharikovpro","id":2053886,"avatar_url":"https://avatars.githubusercontent.com/u/2053886?v=3","gravatar_id":"","url":"https://api.github.com/users/zharikovpro","html_url":"https://github.com/zharikovpro","followers_url":"https://api.github.com/users/zharikovpro/followers","following_url":"https://api.github.com/users/zharikovpro/following{/other_user}","gists_url":"https://api.github.com/users/zharikovpro/gists{/gist_id}","starred_url":"https://api.github.com/users/zharikovpro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zharikovpro/subscriptions","organizations_url":"https://api.github.com/users/zharikovpro/orgs","repos_url":"https://api.github.com/users/zharikovpro/repos","events_url":"https://api.github.com/users/zharikovpro/events{/privacy}","received_events_url":"https://api.github.com/users/zharikovpro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zharikovpro/acts_as_list","description":"An ActiveRecord plugin for managing lists.","fork":true,"url":"https://api.github.com/repos/zharikovpro/acts_as_list","forks_url":"https://api.github.com/repos/zharikovpro/acts_as_list/forks","keys_url":"https://api.github.com/repos/zharikovpro/acts_as_list/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zharikovpro/acts_as_list/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zharikovpro/acts_as_list/teams","hooks_url":"https://api.github.com/repos/zharikovpro/acts_as_list/hooks","issue_events_url":"https://api.github.com/repos/zharikovpro/acts_as_list/issues/events{/number}","events_url":"https://api.github.com/repos/zharikovpro/acts_as_list/events","assignees_url":"https://api.github.com/repos/zharikovpro/acts_as_list/assignees{/user}","branches_url":"https://api.github.com/repos/zharikovpro/acts_as_list/branches{/branch}","tags_url":"https://api.github.com/repos/zharikovpro/acts_as_list/tags","blobs_url":"https://api.github.com/repos/zharikovpro/acts_as_list/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zharikovpro/acts_as_list/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zharikovpro/acts_as_list/git/refs{/sha}","trees_url":"https://api.github.com/repos/zharikovpro/acts_as_list/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zharikovpro/acts_as_list/statuses/{sha}","languages_url":"https://api.github.com/repos/zharikovpro/acts_as_list/languages","stargazers_url":"https://api.github.com/repos/zharikovpro/acts_as_list/stargazers","contributors_url":"https://api.github.com/repos/zharikovpro/acts_as_list/contributors","subscribers_url":"https://api.github.com/repos/zharikovpro/acts_as_list/subscribers","subscription_url":"https://api.github.com/repos/zharikovpro/acts_as_list/subscription","commits_url":"https://api.github.com/repos/zharikovpro/acts_as_list/commits{/sha}","git_commits_url":"https://api.github.com/repos/zharikovpro/acts_as_list/git/commits{/sha}","comments_url":"https://api.github.com/repos/zharikovpro/acts_as_list/comments{/number}","issue_comment_url":"https://api.github.com/repos/zharikovpro/acts_as_list/issues/comments{/number}","contents_url":"https://api.github.com/repos/zharikovpro/acts_as_list/contents/{+path}","compare_url":"https://api.github.com/repos/zharikovpro/acts_as_list/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zharikovpro/acts_as_list/merges","archive_url":"https://api.github.com/repos/zharikovpro/acts_as_list/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zharikovpro/acts_as_list/downloads","issues_url":"https://api.github.com/repos/zharikovpro/acts_as_list/issues{/number}","pulls_url":"https://api.github.com/repos/zharikovpro/acts_as_list/pulls{/number}","milestones_url":"https://api.github.com/repos/zharikovpro/acts_as_list/milestones{/number}","notifications_url":"https://api.github.com/repos/zharikovpro/acts_as_list/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zharikovpro/acts_as_list/labels{/name}","releases_url":"https://api.github.com/repos/zharikovpro/acts_as_list/releases{/id}","deployments_url":"https://api.github.com/repos/zharikovpro/acts_as_list/deployments","created_at":"2016-12-22T20:11:25Z","updated_at":"2016-12-22T20:11:29Z","pushed_at":"2016-12-26T11:46:19Z","git_url":"git://github.com/zharikovpro/acts_as_list.git","ssh_url":"git@github.com:zharikovpro/acts_as_list.git","clone_url":"https://github.com/zharikovpro/acts_as_list.git","svn_url":"https://github.com/zharikovpro/acts_as_list","homepage":"http://swanandp.github.io/acts_as_list/","size":418,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"swanandp:master","ref":"master","sha":"83abef9f25edce7296d80fdc72c4061d723e641d","user":{"login":"swanandp","id":90904,"avatar_url":"https://avatars.githubusercontent.com/u/90904?v=3","gravatar_id":"","url":"https://api.github.com/users/swanandp","html_url":"https://github.com/swanandp","followers_url":"https://api.github.com/users/swanandp/followers","following_url":"https://api.github.com/users/swanandp/following{/other_user}","gists_url":"https://api.github.com/users/swanandp/gists{/gist_id}","starred_url":"https://api.github.com/users/swanandp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swanandp/subscriptions","organizations_url":"https://api.github.com/users/swanandp/orgs","repos_url":"https://api.github.com/users/swanandp/repos","events_url":"https://api.github.com/users/swanandp/events{/privacy}","received_events_url":"https://api.github.com/users/swanandp/received_events","type":"User","site_admin":false},"repo":{"id":1330786,"name":"acts_as_list","full_name":"swanandp/acts_as_list","owner":{"login":"swanandp","id":90904,"avatar_url":"https://avatars.githubusercontent.com/u/90904?v=3","gravatar_id":"","url":"https://api.github.com/users/swanandp","html_url":"https://github.com/swanandp","followers_url":"https://api.github.com/users/swanandp/followers","following_url":"https://api.github.com/users/swanandp/following{/other_user}","gists_url":"https://api.github.com/users/swanandp/gists{/gist_id}","starred_url":"https://api.github.com/users/swanandp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swanandp/subscriptions","organizations_url":"https://api.github.com/users/swanandp/orgs","repos_url":"https://api.github.com/users/swanandp/repos","events_url":"https://api.github.com/users/swanandp/events{/privacy}","received_events_url":"https://api.github.com/users/swanandp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/swanandp/acts_as_list","description":"An ActiveRecord plugin for managing lists.","fork":false,"url":"https://api.github.com/repos/swanandp/acts_as_list","forks_url":"https://api.github.com/repos/swanandp/acts_as_list/forks","keys_url":"https://api.github.com/repos/swanandp/acts_as_list/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swanandp/acts_as_list/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swanandp/acts_as_list/teams","hooks_url":"https://api.github.com/repos/swanandp/acts_as_list/hooks","issue_events_url":"https://api.github.com/repos/swanandp/acts_as_list/issues/events{/number}","events_url":"https://api.github.com/repos/swanandp/acts_as_list/events","assignees_url":"https://api.github.com/repos/swanandp/acts_as_list/assignees{/user}","branches_url":"https://api.github.com/repos/swanandp/acts_as_list/branches{/branch}","tags_url":"https://api.github.com/repos/swanandp/acts_as_list/tags","blobs_url":"https://api.github.com/repos/swanandp/acts_as_list/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swanandp/acts_as_list/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swanandp/acts_as_list/git/refs{/sha}","trees_url":"https://api.github.com/repos/swanandp/acts_as_list/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swanandp/acts_as_list/statuses/{sha}","languages_url":"https://api.github.com/repos/swanandp/acts_as_list/languages","stargazers_url":"https://api.github.com/repos/swanandp/acts_as_list/stargazers","contributors_url":"https://api.github.com/repos/swanandp/acts_as_list/contributors","subscribers_url":"https://api.github.com/repos/swanandp/acts_as_list/subscribers","subscription_url":"https://api.github.com/repos/swanandp/acts_as_list/subscription","commits_url":"https://api.github.com/repos/swanandp/acts_as_list/commits{/sha}","git_commits_url":"https://api.github.com/repos/swanandp/acts_as_list/git/commits{/sha}","comments_url":"https://api.github.com/repos/swanandp/acts_as_list/comments{/number}","issue_comment_url":"https://api.github.com/repos/swanandp/acts_as_list/issues/comments{/number}","contents_url":"https://api.github.com/repos/swanandp/acts_as_list/contents/{+path}","compare_url":"https://api.github.com/repos/swanandp/acts_as_list/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swanandp/acts_as_list/merges","archive_url":"https://api.github.com/repos/swanandp/acts_as_list/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swanandp/acts_as_list/downloads","issues_url":"https://api.github.com/repos/swanandp/acts_as_list/issues{/number}","pulls_url":"https://api.github.com/repos/swanandp/acts_as_list/pulls{/number}","milestones_url":"https://api.github.com/repos/swanandp/acts_as_list/milestones{/number}","notifications_url":"https://api.github.com/repos/swanandp/acts_as_list/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swanandp/acts_as_list/labels{/name}","releases_url":"https://api.github.com/repos/swanandp/acts_as_list/releases{/id}","deployments_url":"https://api.github.com/repos/swanandp/acts_as_list/deployments","created_at":"2011-02-05T06:39:01Z","updated_at":"2016-12-27T09:17:08Z","pushed_at":"2016-12-23T22:33:37Z","git_url":"git://github.com/swanandp/acts_as_list.git","ssh_url":"git@github.com:swanandp/acts_as_list.git","clone_url":"https://github.com/swanandp/acts_as_list.git","svn_url":"https://github.com/swanandp/acts_as_list","homepage":"http://swanandp.github.io/acts_as_list/","size":571,"stargazers_count":1080,"watchers_count":1080,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":256,"mirror_url":null,"open_issues_count":11,"forks":256,"open_issues":11,"watchers":1080,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/swanandp/acts_as_list/pulls/246"},"html":{"href":"https://github.com/swanandp/acts_as_list/pull/246"},"issue":{"href":"https://api.github.com/repos/swanandp/acts_as_list/issues/246"},"comments":{"href":"https://api.github.com/repos/swanandp/acts_as_list/issues/246/comments"},"review_comments":{"href":"https://api.github.com/repos/swanandp/acts_as_list/pulls/246/comments"},"review_comment":{"href":"https://api.github.com/repos/swanandp/acts_as_list/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/swanandp/acts_as_list/pulls/246/commits"},"statuses":{"href":"https://api.github.com/repos/swanandp/acts_as_list/statuses/83cdf798a3ec21410c8263cf867b0206ce3ca905"}}}}
{"actor":{"display_login":"brendon"}}