{"action":"created","comment":{"url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/comments/22830861","id":22830861,"diff_hunk":"@@ -437,23 +459,59 @@ private void syncDownSosl(SyncState sync, SyncUpdateCallback callback) throws Ex\n \t\t}\n \t\treturn arr;\n \t}\n+\n+    private Set<String> toSet(JSONArray jsonArray) throws JSONException {\n+        Set<String> set = new HashSet<String>();\n+        for (int i=0; i<jsonArray.length(); i++) {\n+            set.add(jsonArray.getJSONArray(i).getString(0));\n+        }\n+        return set;\n+    }\n \t\n-\tprivate void saveRecordsToSmartStore(String soupName, JSONArray records)\n+\tprivate void saveRecordsToSmartStore(String soupName, JSONArray records, MergeMode mergeMode)\n \t\t\tthrows JSONException {\n-\t\t// Save to SmartStore\n+        // Gather ids of dirty records\n+        Set<String> idsToSkip = null;","path":"libs/SmartSync/src/com/salesforce/androidsdk/smartsync/manager/SyncManager.java","position":320,"original_position":320,"commit_id":"6fb36f7817e3278b77b847b8fbc0459e065eb6f2","original_commit_id":"6fb36f7817e3278b77b847b8fbc0459e065eb6f2","user":{"login":"wmathurin","id":1012459,"avatar_url":"https://avatars.githubusercontent.com/u/1012459?v=3","gravatar_id":"","url":"https://api.github.com/users/wmathurin","html_url":"https://github.com/wmathurin","followers_url":"https://api.github.com/users/wmathurin/followers","following_url":"https://api.github.com/users/wmathurin/following{/other_user}","gists_url":"https://api.github.com/users/wmathurin/gists{/gist_id}","starred_url":"https://api.github.com/users/wmathurin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmathurin/subscriptions","organizations_url":"https://api.github.com/users/wmathurin/orgs","repos_url":"https://api.github.com/users/wmathurin/repos","events_url":"https://api.github.com/users/wmathurin/events{/privacy}","received_events_url":"https://api.github.com/users/wmathurin/received_events","type":"User","site_admin":false},"body":"Approach: we get the ids of ALL the dirty records and skip them when saving records fetched from the server.\r\nWe don't do a:\r\nselect id where dirty and id in (ids fetched from server) \r\nbecause the list of ids could be to long and we would have to chunk up the query etc. \r\n\r\nWe don't expect to many records changed locally, so the full list should be \"small\" most of the time.","created_at":"2015-01-12T23:04:08Z","updated_at":"2015-01-12T23:04:08Z","html_url":"https://github.com/forcedotcom/SalesforceMobileSDK-Android/pull/796#discussion_r22830861","pull_request_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/796","_links":{"self":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/comments/22830861"},"html":{"href":"https://github.com/forcedotcom/SalesforceMobileSDK-Android/pull/796#discussion_r22830861"},"pull_request":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/796"}}},"pull_request":{"url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/796","id":27233048,"html_url":"https://github.com/forcedotcom/SalesforceMobileSDK-Android/pull/796","diff_url":"https://github.com/forcedotcom/SalesforceMobileSDK-Android/pull/796.diff","patch_url":"https://github.com/forcedotcom/SalesforceMobileSDK-Android/pull/796.patch","issue_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/issues/796","number":796,"state":"open","locked":false,"title":"New option on sync down to leave alone \"dirty\" records","user":{"login":"wmathurin","id":1012459,"avatar_url":"https://avatars.githubusercontent.com/u/1012459?v=3","gravatar_id":"","url":"https://api.github.com/users/wmathurin","html_url":"https://github.com/wmathurin","followers_url":"https://api.github.com/users/wmathurin/followers","following_url":"https://api.github.com/users/wmathurin/following{/other_user}","gists_url":"https://api.github.com/users/wmathurin/gists{/gist_id}","starred_url":"https://api.github.com/users/wmathurin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmathurin/subscriptions","organizations_url":"https://api.github.com/users/wmathurin/orgs","repos_url":"https://api.github.com/users/wmathurin/repos","events_url":"https://api.github.com/users/wmathurin/events{/privacy}","received_events_url":"https://api.github.com/users/wmathurin/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-12T22:43:29Z","updated_at":"2015-01-12T23:04:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e8603af0507fa1bb767a053902a04057941eb4b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/796/commits","review_comments_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/796/comments","review_comment_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/comments/{number}","comments_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/issues/796/comments","statuses_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/statuses/6fb36f7817e3278b77b847b8fbc0459e065eb6f2","head":{"label":"wmathurin:smartsync","ref":"smartsync","sha":"6fb36f7817e3278b77b847b8fbc0459e065eb6f2","user":{"login":"wmathurin","id":1012459,"avatar_url":"https://avatars.githubusercontent.com/u/1012459?v=3","gravatar_id":"","url":"https://api.github.com/users/wmathurin","html_url":"https://github.com/wmathurin","followers_url":"https://api.github.com/users/wmathurin/followers","following_url":"https://api.github.com/users/wmathurin/following{/other_user}","gists_url":"https://api.github.com/users/wmathurin/gists{/gist_id}","starred_url":"https://api.github.com/users/wmathurin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmathurin/subscriptions","organizations_url":"https://api.github.com/users/wmathurin/orgs","repos_url":"https://api.github.com/users/wmathurin/repos","events_url":"https://api.github.com/users/wmathurin/events{/privacy}","received_events_url":"https://api.github.com/users/wmathurin/received_events","type":"User","site_admin":false},"repo":{"id":5184182,"name":"SalesforceMobileSDK-Android","full_name":"wmathurin/SalesforceMobileSDK-Android","owner":{"login":"wmathurin","id":1012459,"avatar_url":"https://avatars.githubusercontent.com/u/1012459?v=3","gravatar_id":"","url":"https://api.github.com/users/wmathurin","html_url":"https://github.com/wmathurin","followers_url":"https://api.github.com/users/wmathurin/followers","following_url":"https://api.github.com/users/wmathurin/following{/other_user}","gists_url":"https://api.github.com/users/wmathurin/gists{/gist_id}","starred_url":"https://api.github.com/users/wmathurin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmathurin/subscriptions","organizations_url":"https://api.github.com/users/wmathurin/orgs","repos_url":"https://api.github.com/users/wmathurin/repos","events_url":"https://api.github.com/users/wmathurin/events{/privacy}","received_events_url":"https://api.github.com/users/wmathurin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wmathurin/SalesforceMobileSDK-Android","description":"Android SDK for Salesforce","fork":true,"url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android","forks_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/forks","keys_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/teams","hooks_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/hooks","issue_events_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/issues/events{/number}","events_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/events","assignees_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/assignees{/user}","branches_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/branches{/branch}","tags_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/tags","blobs_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/languages","stargazers_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/stargazers","contributors_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/contributors","subscribers_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/subscribers","subscription_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/subscription","commits_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/issues/comments/{number}","contents_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/contents/{+path}","compare_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/merges","archive_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/downloads","issues_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/issues{/number}","pulls_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/labels{/name}","releases_url":"https://api.github.com/repos/wmathurin/SalesforceMobileSDK-Android/releases{/id}","created_at":"2012-07-25T20:30:08Z","updated_at":"2014-12-01T22:55:20Z","pushed_at":"2015-01-12T22:42:12Z","git_url":"git://github.com/wmathurin/SalesforceMobileSDK-Android.git","ssh_url":"git@github.com:wmathurin/SalesforceMobileSDK-Android.git","clone_url":"https://github.com/wmathurin/SalesforceMobileSDK-Android.git","svn_url":"https://github.com/wmathurin/SalesforceMobileSDK-Android","homepage":"","size":44783,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"forcedotcom:unstable","ref":"unstable","sha":"3d4a67c57f7e4c3b20207d0193832594bb52c812","user":{"login":"forcedotcom","id":464563,"avatar_url":"https://avatars.githubusercontent.com/u/464563?v=3","gravatar_id":"","url":"https://api.github.com/users/forcedotcom","html_url":"https://github.com/forcedotcom","followers_url":"https://api.github.com/users/forcedotcom/followers","following_url":"https://api.github.com/users/forcedotcom/following{/other_user}","gists_url":"https://api.github.com/users/forcedotcom/gists{/gist_id}","starred_url":"https://api.github.com/users/forcedotcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forcedotcom/subscriptions","organizations_url":"https://api.github.com/users/forcedotcom/orgs","repos_url":"https://api.github.com/users/forcedotcom/repos","events_url":"https://api.github.com/users/forcedotcom/events{/privacy}","received_events_url":"https://api.github.com/users/forcedotcom/received_events","type":"Organization","site_admin":false},"repo":{"id":2782691,"name":"SalesforceMobileSDK-Android","full_name":"forcedotcom/SalesforceMobileSDK-Android","owner":{"login":"forcedotcom","id":464563,"avatar_url":"https://avatars.githubusercontent.com/u/464563?v=3","gravatar_id":"","url":"https://api.github.com/users/forcedotcom","html_url":"https://github.com/forcedotcom","followers_url":"https://api.github.com/users/forcedotcom/followers","following_url":"https://api.github.com/users/forcedotcom/following{/other_user}","gists_url":"https://api.github.com/users/forcedotcom/gists{/gist_id}","starred_url":"https://api.github.com/users/forcedotcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forcedotcom/subscriptions","organizations_url":"https://api.github.com/users/forcedotcom/orgs","repos_url":"https://api.github.com/users/forcedotcom/repos","events_url":"https://api.github.com/users/forcedotcom/events{/privacy}","received_events_url":"https://api.github.com/users/forcedotcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/forcedotcom/SalesforceMobileSDK-Android","description":"Android SDK for Salesforce","fork":false,"url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android","forks_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/forks","keys_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/teams","hooks_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/hooks","issue_events_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/issues/events{/number}","events_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/events","assignees_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/assignees{/user}","branches_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/branches{/branch}","tags_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/tags","blobs_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/languages","stargazers_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/stargazers","contributors_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/contributors","subscribers_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/subscribers","subscription_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/subscription","commits_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/issues/comments/{number}","contents_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/contents/{+path}","compare_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/merges","archive_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/downloads","issues_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/issues{/number}","pulls_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/labels{/name}","releases_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/releases{/id}","created_at":"2011-11-15T19:35:05Z","updated_at":"2014-12-28T20:27:19Z","pushed_at":"2015-01-08T21:45:09Z","git_url":"git://github.com/forcedotcom/SalesforceMobileSDK-Android.git","ssh_url":"git@github.com:forcedotcom/SalesforceMobileSDK-Android.git","clone_url":"https://github.com/forcedotcom/SalesforceMobileSDK-Android.git","svn_url":"https://github.com/forcedotcom/SalesforceMobileSDK-Android","homepage":"","size":47692,"stargazers_count":160,"watchers_count":160,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":203,"mirror_url":null,"open_issues_count":6,"forks":203,"open_issues":6,"watchers":160,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/796"},"html":{"href":"https://github.com/forcedotcom/SalesforceMobileSDK-Android/pull/796"},"issue":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/issues/796"},"comments":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/issues/796/comments"},"review_comments":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/796/comments"},"review_comment":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/pulls/796/commits"},"statuses":{"href":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-Android/statuses/6fb36f7817e3278b77b847b8fbc0459e065eb6f2"}}}}