{"action":"created","issue":{"url":"https://api.github.com/repos/biocore/qiita/issues/1276","labels_url":"https://api.github.com/repos/biocore/qiita/issues/1276/labels{/name}","comments_url":"https://api.github.com/repos/biocore/qiita/issues/1276/comments","events_url":"https://api.github.com/repos/biocore/qiita/issues/1276/events","html_url":"https://github.com/biocore/qiita/pull/1276","id":89602168,"number":1276,"title":"Add `Transaction` object","user":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/biocore/qiita/labels/priority:%20high","name":"priority: high","color":"CE1126"},{"url":"https://api.github.com/repos/biocore/qiita/labels/refactor","name":"refactor","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/biocore/qiita/milestones/8","html_url":"https://github.com/biocore/qiita/milestones/Alpha%200.2","labels_url":"https://api.github.com/repos/biocore/qiita/milestones/8/labels","id":1049807,"number":8,"title":"Alpha 0.2","description":"","creator":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"open_issues":68,"closed_issues":71,"state":"open","created_at":"2015-04-02T04:52:07Z","updated_at":"2015-06-23T18:32:11Z","due_on":"2015-07-03T07:00:00Z","closed_at":null},"comments":29,"created_at":"2015-06-19T16:13:00Z","updated_at":"2015-06-23T21:02:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/biocore/qiita/pulls/1276","html_url":"https://github.com/biocore/qiita/pull/1276","diff_url":"https://github.com/biocore/qiita/pull/1276.diff","patch_url":"https://github.com/biocore/qiita/pull/1276.patch"},"body":"This PR is the first of a series of PR to be able to modify Qiita DB to make use of transactions everywhere.\r\n\r\nAs discussed in the last meeting, instead of modifying the current queue system it will be better to add a `Transaction` object that encapsulates the transaction.\r\n\r\nA few changes from the original design:\r\n - The placeholders, instead of being of the form `{#:#} -> {query_idx:result_idx}` are of the form `{#:#:#} -> {query_idx:row_id:value_idx}`. This allow for more flexibility and it is easier to reference an actual result. It also removes the need of flattening the results.\r\n - The `execute` method has a boolean parameter `commit`, optional and default `True`. This allows to execute all the current queries in the transaction without committing it, which is useful if you need an intermediate result of the transaction to execute some python code (e.g. instantiate an object to retrieve some other information needed for adding more queries to the DB)\r\n - The `execute` methods returns always all the results. You can retrieve then a specific result using the index, or using `[-1]` to retrieve the result of the last query. This last part was impossible before unless you knew how many results where returned by the last query.\r\n\r\nThe tests are expected to fail, since the rest of the code has not been modified. Those will be further PR."},"comment":{"url":"https://api.github.com/repos/biocore/qiita/issues/comments/114641026","html_url":"https://github.com/biocore/qiita/pull/1276#issuecomment-114641026","issue_url":"https://api.github.com/repos/biocore/qiita/issues/1276","id":114641026,"user":{"login":"ElDeveloper","id":375307,"avatar_url":"https://avatars.githubusercontent.com/u/375307?v=3","gravatar_id":"","url":"https://api.github.com/users/ElDeveloper","html_url":"https://github.com/ElDeveloper","followers_url":"https://api.github.com/users/ElDeveloper/followers","following_url":"https://api.github.com/users/ElDeveloper/following{/other_user}","gists_url":"https://api.github.com/users/ElDeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/ElDeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElDeveloper/subscriptions","organizations_url":"https://api.github.com/users/ElDeveloper/orgs","repos_url":"https://api.github.com/users/ElDeveloper/repos","events_url":"https://api.github.com/users/ElDeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/ElDeveloper/received_events","type":"User","site_admin":false},"created_at":"2015-06-23T21:02:20Z","updated_at":"2015-06-23T21:02:20Z","body":"I'm having a look at this right now.\n\nOn (Jun-23-15|11:30), josenavas wrote:\n> @wasade @squirrelo @ElDeveloper \n> \n> I've updated the Transaction object to be a context manager. Few things to note:\n>  - The Transaction does not try to automatically execute in the `__exit__`. I've tried it and it generated some unexpected behavior (try to execute things have previously errored). Also, I prefer to have things explicit rather than implicit. Idea: Do not modify the DB if the programmer do not ask for it.\n>  - I did not remove the old queue system code. The reason behind this is we can then execute the tests and tests **now should pass**. I've added a comment in #1262 so we don't forget.\n>  - The 'execute' code has been moved to an internal `_execute` function and the exposed `execute` wraps the `_execute` one in a try/except, so we can catch and rollback any changes in there.\n> \n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/biocore/qiita/pull/1276#issuecomment-114600592\n"}}