{"action":"created","comment":{"url":"https://api.github.com/repos/realm/realm-java/pulls/comments/24488812","id":24488812,"diff_hunk":"@@ -431,4 +433,148 @@ public void testCreateObjectFromJsonStream_nullValues() throws IOException {\n         assertNull(obj.getColumnRealmObject());\n         assertEquals(0, obj.getColumnRealmList().size());\n     }\n-}\n+\n+    public void testCreateOrUpdateObject_noPrimaryKeyThrows() {\n+        try {\n+            testRealm.createOrUpdateObjectFromJson(AllTypes.class, new JSONObject());\n+        } catch (IllegalArgumentException expected) {\n+            return;\n+        }\n+        fail();","path":"realm/src/androidTest/java/io/realm/RealmJsonTest.java","position":26,"original_position":26,"commit_id":"aefd14dcff6f135d9b055ea20d84707e805b8b3d","original_commit_id":"aefd14dcff6f135d9b055ea20d84707e805b8b3d","user":{"login":"kneth","id":1225363,"avatar_url":"https://avatars.githubusercontent.com/u/1225363?v=3","gravatar_id":"","url":"https://api.github.com/users/kneth","html_url":"https://github.com/kneth","followers_url":"https://api.github.com/users/kneth/followers","following_url":"https://api.github.com/users/kneth/following{/other_user}","gists_url":"https://api.github.com/users/kneth/gists{/gist_id}","starred_url":"https://api.github.com/users/kneth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kneth/subscriptions","organizations_url":"https://api.github.com/users/kneth/orgs","repos_url":"https://api.github.com/users/kneth/repos","events_url":"https://api.github.com/users/kneth/events{/privacy}","received_events_url":"https://api.github.com/users/kneth/received_events","type":"User","site_admin":false},"body":"Why not move `fail()` into `try` block?","created_at":"2015-02-11T11:36:39Z","updated_at":"2015-02-11T11:36:39Z","html_url":"https://github.com/realm/realm-java/pull/827#discussion_r24488812","pull_request_url":"https://api.github.com/repos/realm/realm-java/pulls/827","_links":{"self":{"href":"https://api.github.com/repos/realm/realm-java/pulls/comments/24488812"},"html":{"href":"https://github.com/realm/realm-java/pull/827#discussion_r24488812"},"pull_request":{"href":"https://api.github.com/repos/realm/realm-java/pulls/827"}}},"pull_request":{"url":"https://api.github.com/repos/realm/realm-java/pulls/827","id":28790598,"html_url":"https://github.com/realm/realm-java/pull/827","diff_url":"https://github.com/realm/realm-java/pull/827.diff","patch_url":"https://github.com/realm/realm-java/pull/827.patch","issue_url":"https://api.github.com/repos/realm/realm-java/issues/827","number":827,"state":"open","locked":false,"title":"Adding support for createOrUpdate methods","user":{"login":"cmelchior","id":406066,"avatar_url":"https://avatars.githubusercontent.com/u/406066?v=3","gravatar_id":"","url":"https://api.github.com/users/cmelchior","html_url":"https://github.com/cmelchior","followers_url":"https://api.github.com/users/cmelchior/followers","following_url":"https://api.github.com/users/cmelchior/following{/other_user}","gists_url":"https://api.github.com/users/cmelchior/gists{/gist_id}","starred_url":"https://api.github.com/users/cmelchior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmelchior/subscriptions","organizations_url":"https://api.github.com/users/cmelchior/orgs","repos_url":"https://api.github.com/users/cmelchior/repos","events_url":"https://api.github.com/users/cmelchior/events{/privacy}","received_events_url":"https://api.github.com/users/cmelchior/received_events","type":"User","site_admin":false},"body":"This PR extends https://github.com/realm/realm-java/pull/565 with createOrUpdate methods.\r\nJson support has been refactored due to this to be able to support both standalone and managed objects.\r\n\r\nThe following methods has been added for JSON: \r\n```\r\nRealm.createOrUpdateObjectFromJson(Class, JSONObject)\r\nRealm.createOrUpdateObjectFromJson(Class, InputStream)\r\nRealm.createOrUpdateObjectFromJson(Class, String)\r\nRealm.createOrUpdateAllFromJson(Class, JSONArray)\r\nRealm.createOrUpdateAllFromJson(Class, InputStream)\r\nRealm.createOrUpdateAllFromJson(Class, String)\r\n```\r\n\r\nAnd for standalone objects\r\n```\r\nRealm.copyToRealmOrUpdate(RealmObject)\r\nRealm.copyToRealmOrUpdate(Iterable RealmObject)\r\n```\r\n\r\nEspecially the last two gets a bit long winded and could probably use some iteration on naming, other suggestions\r\n```\r\nRealm.createOrUpdate(RealmObject); // From iOS\r\nRealm.addOrUpdate(RealmObject); \r\nRealm.copyOrUpdateToRealm(RealmObject); // similar naming scheme as JSON methods\r\nRealm.copyOrUpdate(RealmObject); // shorter, would imply that copyToRealm gets renamed to copy()\r\nRealm.updateOrCopyToRealm(RealmObject); // emphasis on updates, which is the primary use case.\r\nRealm.copyToRealm(RealmObject,  Flag); // Flags could be UPDATE, , INSERT\r\nRealm.update(RealmObject); // only updates, return null if object couldn't be updated.\r\n```\r\n\r\n\r\n\r\n\r\n\r\n","created_at":"2015-02-06T07:47:18Z","updated_at":"2015-02-11T11:36:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d01040e16d219a4a84adc54ce299e46a3ce0f087","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/realm/realm-java/pulls/827/commits","review_comments_url":"https://api.github.com/repos/realm/realm-java/pulls/827/comments","review_comment_url":"https://api.github.com/repos/realm/realm-java/pulls/comments/{number}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/827/comments","statuses_url":"https://api.github.com/repos/realm/realm-java/statuses/aefd14dcff6f135d9b055ea20d84707e805b8b3d","head":{"label":"realm:cm-update-methods","ref":"cm-update-methods","sha":"aefd14dcff6f135d9b055ea20d84707e805b8b3d","user":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"repo":{"id":4084908,"name":"realm-java","full_name":"realm/realm-java","owner":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/realm/realm-java","description":"Realm is a mobile database: a replacement for SQLite & ORMs","fork":false,"url":"https://api.github.com/repos/realm/realm-java","forks_url":"https://api.github.com/repos/realm/realm-java/forks","keys_url":"https://api.github.com/repos/realm/realm-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realm/realm-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realm/realm-java/teams","hooks_url":"https://api.github.com/repos/realm/realm-java/hooks","issue_events_url":"https://api.github.com/repos/realm/realm-java/issues/events{/number}","events_url":"https://api.github.com/repos/realm/realm-java/events","assignees_url":"https://api.github.com/repos/realm/realm-java/assignees{/user}","branches_url":"https://api.github.com/repos/realm/realm-java/branches{/branch}","tags_url":"https://api.github.com/repos/realm/realm-java/tags","blobs_url":"https://api.github.com/repos/realm/realm-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realm/realm-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realm/realm-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/realm/realm-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realm/realm-java/statuses/{sha}","languages_url":"https://api.github.com/repos/realm/realm-java/languages","stargazers_url":"https://api.github.com/repos/realm/realm-java/stargazers","contributors_url":"https://api.github.com/repos/realm/realm-java/contributors","subscribers_url":"https://api.github.com/repos/realm/realm-java/subscribers","subscription_url":"https://api.github.com/repos/realm/realm-java/subscription","commits_url":"https://api.github.com/repos/realm/realm-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/realm/realm-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/realm/realm-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/realm/realm-java/issues/comments/{number}","contents_url":"https://api.github.com/repos/realm/realm-java/contents/{+path}","compare_url":"https://api.github.com/repos/realm/realm-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realm/realm-java/merges","archive_url":"https://api.github.com/repos/realm/realm-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realm/realm-java/downloads","issues_url":"https://api.github.com/repos/realm/realm-java/issues{/number}","pulls_url":"https://api.github.com/repos/realm/realm-java/pulls{/number}","milestones_url":"https://api.github.com/repos/realm/realm-java/milestones{/number}","notifications_url":"https://api.github.com/repos/realm/realm-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realm/realm-java/labels{/name}","releases_url":"https://api.github.com/repos/realm/realm-java/releases{/id}","created_at":"2012-04-20T09:18:42Z","updated_at":"2015-02-11T11:04:00Z","pushed_at":"2015-02-11T11:04:00Z","git_url":"git://github.com/realm/realm-java.git","ssh_url":"git@github.com:realm/realm-java.git","clone_url":"https://github.com/realm/realm-java.git","svn_url":"https://github.com/realm/realm-java","homepage":"http://realm.io","size":49982,"stargazers_count":1246,"watchers_count":1246,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":93,"mirror_url":null,"open_issues_count":68,"forks":93,"open_issues":68,"watchers":1246,"default_branch":"master"}},"base":{"label":"realm:master","ref":"master","sha":"590f846128bb13712547ffa1dccce4e1c61b5249","user":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"repo":{"id":4084908,"name":"realm-java","full_name":"realm/realm-java","owner":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/realm/realm-java","description":"Realm is a mobile database: a replacement for SQLite & ORMs","fork":false,"url":"https://api.github.com/repos/realm/realm-java","forks_url":"https://api.github.com/repos/realm/realm-java/forks","keys_url":"https://api.github.com/repos/realm/realm-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realm/realm-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realm/realm-java/teams","hooks_url":"https://api.github.com/repos/realm/realm-java/hooks","issue_events_url":"https://api.github.com/repos/realm/realm-java/issues/events{/number}","events_url":"https://api.github.com/repos/realm/realm-java/events","assignees_url":"https://api.github.com/repos/realm/realm-java/assignees{/user}","branches_url":"https://api.github.com/repos/realm/realm-java/branches{/branch}","tags_url":"https://api.github.com/repos/realm/realm-java/tags","blobs_url":"https://api.github.com/repos/realm/realm-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realm/realm-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realm/realm-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/realm/realm-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realm/realm-java/statuses/{sha}","languages_url":"https://api.github.com/repos/realm/realm-java/languages","stargazers_url":"https://api.github.com/repos/realm/realm-java/stargazers","contributors_url":"https://api.github.com/repos/realm/realm-java/contributors","subscribers_url":"https://api.github.com/repos/realm/realm-java/subscribers","subscription_url":"https://api.github.com/repos/realm/realm-java/subscription","commits_url":"https://api.github.com/repos/realm/realm-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/realm/realm-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/realm/realm-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/realm/realm-java/issues/comments/{number}","contents_url":"https://api.github.com/repos/realm/realm-java/contents/{+path}","compare_url":"https://api.github.com/repos/realm/realm-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realm/realm-java/merges","archive_url":"https://api.github.com/repos/realm/realm-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realm/realm-java/downloads","issues_url":"https://api.github.com/repos/realm/realm-java/issues{/number}","pulls_url":"https://api.github.com/repos/realm/realm-java/pulls{/number}","milestones_url":"https://api.github.com/repos/realm/realm-java/milestones{/number}","notifications_url":"https://api.github.com/repos/realm/realm-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realm/realm-java/labels{/name}","releases_url":"https://api.github.com/repos/realm/realm-java/releases{/id}","created_at":"2012-04-20T09:18:42Z","updated_at":"2015-02-11T11:04:00Z","pushed_at":"2015-02-11T11:04:00Z","git_url":"git://github.com/realm/realm-java.git","ssh_url":"git@github.com:realm/realm-java.git","clone_url":"https://github.com/realm/realm-java.git","svn_url":"https://github.com/realm/realm-java","homepage":"http://realm.io","size":49982,"stargazers_count":1246,"watchers_count":1246,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":93,"mirror_url":null,"open_issues_count":68,"forks":93,"open_issues":68,"watchers":1246,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/realm/realm-java/pulls/827"},"html":{"href":"https://github.com/realm/realm-java/pull/827"},"issue":{"href":"https://api.github.com/repos/realm/realm-java/issues/827"},"comments":{"href":"https://api.github.com/repos/realm/realm-java/issues/827/comments"},"review_comments":{"href":"https://api.github.com/repos/realm/realm-java/pulls/827/comments"},"review_comment":{"href":"https://api.github.com/repos/realm/realm-java/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/realm/realm-java/pulls/827/commits"},"statuses":{"href":"https://api.github.com/repos/realm/realm-java/statuses/aefd14dcff6f135d9b055ea20d84707e805b8b3d"}}}}