{"action":"created","comment":{"url":"https://api.github.com/repos/swisscom/cleanerversion/pulls/comments/28868337","id":28868337,"diff_hunk":"@@ -88,17 +100,15 @@ def next_version(self, object):\n         if object.version_end_date == None:\n             return object\n         else:\n-            try:\n-                next = self.get(\n-                    Q(identity=object.identity),\n-                    Q(version_start_date=object.version_end_date))\n-            except MultipleObjectsReturned as e:\n-                raise MultipleObjectsReturned(\n-                    \"next_version couldn't uniquely identify the next version of object \" + str(\n-                        object.identity) + \" to be returned\\n\" + str(e))\n-            except ObjectDoesNotExist as e:\n+            next = self.filter(\n+                Q(identity=object.identity),\n+                Q(version_start_date__gte=object.version_end_date)\n+            ).order_by('version_start_date').first()","path":"versions/models.py","position":61,"original_position":61,"commit_id":"d7dc04b8f906a099d810cb1c6db7fcf7a89ffe1d","original_commit_id":"d7dc04b8f906a099d810cb1c6db7fcf7a89ffe1d","user":{"login":"maennel","id":1587013,"avatar_url":"https://avatars.githubusercontent.com/u/1587013?v=3","gravatar_id":"","url":"https://api.github.com/users/maennel","html_url":"https://github.com/maennel","followers_url":"https://api.github.com/users/maennel/followers","following_url":"https://api.github.com/users/maennel/following{/other_user}","gists_url":"https://api.github.com/users/maennel/gists{/gist_id}","starred_url":"https://api.github.com/users/maennel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maennel/subscriptions","organizations_url":"https://api.github.com/users/maennel/orgs","repos_url":"https://api.github.com/users/maennel/repos","events_url":"https://api.github.com/users/maennel/events{/privacy}","received_events_url":"https://api.github.com/users/maennel/received_events","type":"User","site_admin":false},"body":"Just to be sure, you meant to implement it this way: This means, that 2 versions of a same object can exist at the same time, and CleanerVersion wouldn't complain.","created_at":"2015-04-22T12:49:56Z","updated_at":"2015-04-22T12:49:56Z","html_url":"https://github.com/swisscom/cleanerversion/pull/69#discussion_r28868337","pull_request_url":"https://api.github.com/repos/swisscom/cleanerversion/pulls/69","_links":{"self":{"href":"https://api.github.com/repos/swisscom/cleanerversion/pulls/comments/28868337"},"html":{"href":"https://github.com/swisscom/cleanerversion/pull/69#discussion_r28868337"},"pull_request":{"href":"https://api.github.com/repos/swisscom/cleanerversion/pulls/69"}}},"pull_request":{"url":"https://api.github.com/repos/swisscom/cleanerversion/pulls/69","id":33587944,"html_url":"https://github.com/swisscom/cleanerversion/pull/69","diff_url":"https://github.com/swisscom/cleanerversion/pull/69.diff","patch_url":"https://github.com/swisscom/cleanerversion/pull/69.patch","issue_url":"https://api.github.com/repos/swisscom/cleanerversion/issues/69","number":69,"state":"open","locked":false,"title":"Restorable versions","user":{"login":"brki","id":697240,"avatar_url":"https://avatars.githubusercontent.com/u/697240?v=3","gravatar_id":"","url":"https://api.github.com/users/brki","html_url":"https://github.com/brki","followers_url":"https://api.github.com/users/brki/followers","following_url":"https://api.github.com/users/brki/following{/other_user}","gists_url":"https://api.github.com/users/brki/gists{/gist_id}","starred_url":"https://api.github.com/users/brki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brki/subscriptions","organizations_url":"https://api.github.com/users/brki/orgs","repos_url":"https://api.github.com/users/brki/repos","events_url":"https://api.github.com/users/brki/events{/privacy}","received_events_url":"https://api.github.com/users/brki/received_events","type":"User","site_admin":false},"body":"Allow restoring versions.\r\n\r\nWhen I started, I thought that 50a5369  (allow specifying id and identity at creation time) was necessary to implement this feature.  It turns out not to be necessary, but seems like it could be useful (we considered using it in our project).\r\n\r\nThe deletion handling stuff ensures that related versions, including many-to-many, are properly deleted when a version is deleted.  This seems  important for correct behaviour when versions can be restored.\r\n","created_at":"2015-04-17T22:31:37Z","updated_at":"2015-04-22T12:49:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"080a6ddcdb8339c8541b82ee669e040b884ead2a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/swisscom/cleanerversion/pulls/69/commits","review_comments_url":"https://api.github.com/repos/swisscom/cleanerversion/pulls/69/comments","review_comment_url":"https://api.github.com/repos/swisscom/cleanerversion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/swisscom/cleanerversion/issues/69/comments","statuses_url":"https://api.github.com/repos/swisscom/cleanerversion/statuses/d7dc04b8f906a099d810cb1c6db7fcf7a89ffe1d","head":{"label":"brki:restorable-versions","ref":"restorable-versions","sha":"d7dc04b8f906a099d810cb1c6db7fcf7a89ffe1d","user":{"login":"brki","id":697240,"avatar_url":"https://avatars.githubusercontent.com/u/697240?v=3","gravatar_id":"","url":"https://api.github.com/users/brki","html_url":"https://github.com/brki","followers_url":"https://api.github.com/users/brki/followers","following_url":"https://api.github.com/users/brki/following{/other_user}","gists_url":"https://api.github.com/users/brki/gists{/gist_id}","starred_url":"https://api.github.com/users/brki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brki/subscriptions","organizations_url":"https://api.github.com/users/brki/orgs","repos_url":"https://api.github.com/users/brki/repos","events_url":"https://api.github.com/users/brki/events{/privacy}","received_events_url":"https://api.github.com/users/brki/received_events","type":"User","site_admin":false},"repo":{"id":23952148,"name":"cleanerversion","full_name":"brki/cleanerversion","owner":{"login":"brki","id":697240,"avatar_url":"https://avatars.githubusercontent.com/u/697240?v=3","gravatar_id":"","url":"https://api.github.com/users/brki","html_url":"https://github.com/brki","followers_url":"https://api.github.com/users/brki/followers","following_url":"https://api.github.com/users/brki/following{/other_user}","gists_url":"https://api.github.com/users/brki/gists{/gist_id}","starred_url":"https://api.github.com/users/brki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brki/subscriptions","organizations_url":"https://api.github.com/users/brki/orgs","repos_url":"https://api.github.com/users/brki/repos","events_url":"https://api.github.com/users/brki/events{/privacy}","received_events_url":"https://api.github.com/users/brki/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brki/cleanerversion","description":"CleanerVersion adds a versioning/historizing layer to your relational DB which implements a \"Slowly Changing Dimensions Type 2\" behavior","fork":true,"url":"https://api.github.com/repos/brki/cleanerversion","forks_url":"https://api.github.com/repos/brki/cleanerversion/forks","keys_url":"https://api.github.com/repos/brki/cleanerversion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brki/cleanerversion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brki/cleanerversion/teams","hooks_url":"https://api.github.com/repos/brki/cleanerversion/hooks","issue_events_url":"https://api.github.com/repos/brki/cleanerversion/issues/events{/number}","events_url":"https://api.github.com/repos/brki/cleanerversion/events","assignees_url":"https://api.github.com/repos/brki/cleanerversion/assignees{/user}","branches_url":"https://api.github.com/repos/brki/cleanerversion/branches{/branch}","tags_url":"https://api.github.com/repos/brki/cleanerversion/tags","blobs_url":"https://api.github.com/repos/brki/cleanerversion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brki/cleanerversion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brki/cleanerversion/git/refs{/sha}","trees_url":"https://api.github.com/repos/brki/cleanerversion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brki/cleanerversion/statuses/{sha}","languages_url":"https://api.github.com/repos/brki/cleanerversion/languages","stargazers_url":"https://api.github.com/repos/brki/cleanerversion/stargazers","contributors_url":"https://api.github.com/repos/brki/cleanerversion/contributors","subscribers_url":"https://api.github.com/repos/brki/cleanerversion/subscribers","subscription_url":"https://api.github.com/repos/brki/cleanerversion/subscription","commits_url":"https://api.github.com/repos/brki/cleanerversion/commits{/sha}","git_commits_url":"https://api.github.com/repos/brki/cleanerversion/git/commits{/sha}","comments_url":"https://api.github.com/repos/brki/cleanerversion/comments{/number}","issue_comment_url":"https://api.github.com/repos/brki/cleanerversion/issues/comments{/number}","contents_url":"https://api.github.com/repos/brki/cleanerversion/contents/{+path}","compare_url":"https://api.github.com/repos/brki/cleanerversion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brki/cleanerversion/merges","archive_url":"https://api.github.com/repos/brki/cleanerversion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brki/cleanerversion/downloads","issues_url":"https://api.github.com/repos/brki/cleanerversion/issues{/number}","pulls_url":"https://api.github.com/repos/brki/cleanerversion/pulls{/number}","milestones_url":"https://api.github.com/repos/brki/cleanerversion/milestones{/number}","notifications_url":"https://api.github.com/repos/brki/cleanerversion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brki/cleanerversion/labels{/name}","releases_url":"https://api.github.com/repos/brki/cleanerversion/releases{/id}","created_at":"2014-09-12T08:03:33Z","updated_at":"2014-09-10T16:47:16Z","pushed_at":"2015-04-17T22:09:13Z","git_url":"git://github.com/brki/cleanerversion.git","ssh_url":"git@github.com:brki/cleanerversion.git","clone_url":"https://github.com/brki/cleanerversion.git","svn_url":"https://github.com/brki/cleanerversion","homepage":null,"size":1182,"stargazers_count":0,"watchers_count":0,"language":null,"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":"swisscom:master","ref":"master","sha":"f4454a17deebe7868702235ecb7b51c88663f03f","user":{"login":"swisscom","id":5754111,"avatar_url":"https://avatars.githubusercontent.com/u/5754111?v=3","gravatar_id":"","url":"https://api.github.com/users/swisscom","html_url":"https://github.com/swisscom","followers_url":"https://api.github.com/users/swisscom/followers","following_url":"https://api.github.com/users/swisscom/following{/other_user}","gists_url":"https://api.github.com/users/swisscom/gists{/gist_id}","starred_url":"https://api.github.com/users/swisscom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swisscom/subscriptions","organizations_url":"https://api.github.com/users/swisscom/orgs","repos_url":"https://api.github.com/users/swisscom/repos","events_url":"https://api.github.com/users/swisscom/events{/privacy}","received_events_url":"https://api.github.com/users/swisscom/received_events","type":"Organization","site_admin":false},"repo":{"id":23788348,"name":"cleanerversion","full_name":"swisscom/cleanerversion","owner":{"login":"swisscom","id":5754111,"avatar_url":"https://avatars.githubusercontent.com/u/5754111?v=3","gravatar_id":"","url":"https://api.github.com/users/swisscom","html_url":"https://github.com/swisscom","followers_url":"https://api.github.com/users/swisscom/followers","following_url":"https://api.github.com/users/swisscom/following{/other_user}","gists_url":"https://api.github.com/users/swisscom/gists{/gist_id}","starred_url":"https://api.github.com/users/swisscom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swisscom/subscriptions","organizations_url":"https://api.github.com/users/swisscom/orgs","repos_url":"https://api.github.com/users/swisscom/repos","events_url":"https://api.github.com/users/swisscom/events{/privacy}","received_events_url":"https://api.github.com/users/swisscom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/swisscom/cleanerversion","description":"CleanerVersion adds a versioning/historizing layer to your relational DB which implements a \"Slowly Changing Dimensions Type 2\" behavior","fork":false,"url":"https://api.github.com/repos/swisscom/cleanerversion","forks_url":"https://api.github.com/repos/swisscom/cleanerversion/forks","keys_url":"https://api.github.com/repos/swisscom/cleanerversion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swisscom/cleanerversion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swisscom/cleanerversion/teams","hooks_url":"https://api.github.com/repos/swisscom/cleanerversion/hooks","issue_events_url":"https://api.github.com/repos/swisscom/cleanerversion/issues/events{/number}","events_url":"https://api.github.com/repos/swisscom/cleanerversion/events","assignees_url":"https://api.github.com/repos/swisscom/cleanerversion/assignees{/user}","branches_url":"https://api.github.com/repos/swisscom/cleanerversion/branches{/branch}","tags_url":"https://api.github.com/repos/swisscom/cleanerversion/tags","blobs_url":"https://api.github.com/repos/swisscom/cleanerversion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swisscom/cleanerversion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swisscom/cleanerversion/git/refs{/sha}","trees_url":"https://api.github.com/repos/swisscom/cleanerversion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swisscom/cleanerversion/statuses/{sha}","languages_url":"https://api.github.com/repos/swisscom/cleanerversion/languages","stargazers_url":"https://api.github.com/repos/swisscom/cleanerversion/stargazers","contributors_url":"https://api.github.com/repos/swisscom/cleanerversion/contributors","subscribers_url":"https://api.github.com/repos/swisscom/cleanerversion/subscribers","subscription_url":"https://api.github.com/repos/swisscom/cleanerversion/subscription","commits_url":"https://api.github.com/repos/swisscom/cleanerversion/commits{/sha}","git_commits_url":"https://api.github.com/repos/swisscom/cleanerversion/git/commits{/sha}","comments_url":"https://api.github.com/repos/swisscom/cleanerversion/comments{/number}","issue_comment_url":"https://api.github.com/repos/swisscom/cleanerversion/issues/comments{/number}","contents_url":"https://api.github.com/repos/swisscom/cleanerversion/contents/{+path}","compare_url":"https://api.github.com/repos/swisscom/cleanerversion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swisscom/cleanerversion/merges","archive_url":"https://api.github.com/repos/swisscom/cleanerversion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swisscom/cleanerversion/downloads","issues_url":"https://api.github.com/repos/swisscom/cleanerversion/issues{/number}","pulls_url":"https://api.github.com/repos/swisscom/cleanerversion/pulls{/number}","milestones_url":"https://api.github.com/repos/swisscom/cleanerversion/milestones{/number}","notifications_url":"https://api.github.com/repos/swisscom/cleanerversion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swisscom/cleanerversion/labels{/name}","releases_url":"https://api.github.com/repos/swisscom/cleanerversion/releases{/id}","created_at":"2014-09-08T11:28:31Z","updated_at":"2015-04-21T13:20:52Z","pushed_at":"2015-04-21T13:20:50Z","git_url":"git://github.com/swisscom/cleanerversion.git","ssh_url":"git@github.com:swisscom/cleanerversion.git","clone_url":"https://github.com/swisscom/cleanerversion.git","svn_url":"https://github.com/swisscom/cleanerversion","homepage":null,"size":1549,"stargazers_count":37,"watchers_count":37,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":16,"forks":12,"open_issues":16,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/swisscom/cleanerversion/pulls/69"},"html":{"href":"https://github.com/swisscom/cleanerversion/pull/69"},"issue":{"href":"https://api.github.com/repos/swisscom/cleanerversion/issues/69"},"comments":{"href":"https://api.github.com/repos/swisscom/cleanerversion/issues/69/comments"},"review_comments":{"href":"https://api.github.com/repos/swisscom/cleanerversion/pulls/69/comments"},"review_comment":{"href":"https://api.github.com/repos/swisscom/cleanerversion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/swisscom/cleanerversion/pulls/69/commits"},"statuses":{"href":"https://api.github.com/repos/swisscom/cleanerversion/statuses/d7dc04b8f906a099d810cb1c6db7fcf7a89ffe1d"}}}}