{"action":"created","issue":{"url":"https://api.github.com/repos/coleifer/peewee/issues/1208","repository_url":"https://api.github.com/repos/coleifer/peewee","labels_url":"https://api.github.com/repos/coleifer/peewee/issues/1208/labels{/name}","comments_url":"https://api.github.com/repos/coleifer/peewee/issues/1208/comments","events_url":"https://api.github.com/repos/coleifer/peewee/issues/1208/events","html_url":"https://github.com/coleifer/peewee/issues/1208","id":212038803,"number":1208,"title":"bug on rollback? (peewee==2.8.7)","user":{"login":"paulocheque","id":94350,"avatar_url":"https://avatars2.githubusercontent.com/u/94350?v=3","gravatar_id":"","url":"https://api.github.com/users/paulocheque","html_url":"https://github.com/paulocheque","followers_url":"https://api.github.com/users/paulocheque/followers","following_url":"https://api.github.com/users/paulocheque/following{/other_user}","gists_url":"https://api.github.com/users/paulocheque/gists{/gist_id}","starred_url":"https://api.github.com/users/paulocheque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulocheque/subscriptions","organizations_url":"https://api.github.com/users/paulocheque/orgs","repos_url":"https://api.github.com/users/paulocheque/repos","events_url":"https://api.github.com/users/paulocheque/events{/privacy}","received_events_url":"https://api.github.com/users/paulocheque/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-03-06T06:56:30Z","updated_at":"2017-03-06T19:10:26Z","closed_at":"2017-03-06T15:33:24Z","body":"- Python 3.6\r\n- peewee==2.8.7\r\n\r\n\r\nHi there, In the example below, two records (indexes 0 and 1) will be saved successfully in the database, although I am calling rollback.\r\n\r\n```\r\ndb.connect()\r\nwith db.transaction() as txn:\r\n    for index, row in enumerate(rows):\r\n        try:\r\n            model = MyModel()\r\n            if index == 2:\r\n                raise Exception('This should cancel the entire transaction, right?')\r\n            model.save()\r\n        except Exception as e:\r\n            print('Rollbacking') # yes, lets rollback\r\n            txn.rollback()\r\n            raise # With this, no commit will be made\r\n    print('Commiting') # not being here\r\n    txn.commit()\r\ndb.close()\r\n```\r\n\r\nIs that correct?"},"comment":{"url":"https://api.github.com/repos/coleifer/peewee/issues/comments/284499496","html_url":"https://github.com/coleifer/peewee/issues/1208#issuecomment-284499496","issue_url":"https://api.github.com/repos/coleifer/peewee/issues/1208","id":284499496,"user":{"login":"coleifer","id":119974,"avatar_url":"https://avatars1.githubusercontent.com/u/119974?v=3","gravatar_id":"","url":"https://api.github.com/users/coleifer","html_url":"https://github.com/coleifer","followers_url":"https://api.github.com/users/coleifer/followers","following_url":"https://api.github.com/users/coleifer/following{/other_user}","gists_url":"https://api.github.com/users/coleifer/gists{/gist_id}","starred_url":"https://api.github.com/users/coleifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coleifer/subscriptions","organizations_url":"https://api.github.com/users/coleifer/orgs","repos_url":"https://api.github.com/users/coleifer/repos","events_url":"https://api.github.com/users/coleifer/events{/privacy}","received_events_url":"https://api.github.com/users/coleifer/received_events","type":"User","site_admin":false},"created_at":"2017-03-06T19:10:25Z","updated_at":"2017-03-06T19:10:25Z","body":"@paulocheque -- glad to hear it's working for you. One thing to also consider is the possibility you had nested `transaction()` blocks...Because the semantics of nested transactions may be confusing, I'd recommend using `atomic()` instead. By using `atomic()`, peewee will automatically use a transaction or savepoint where appropriate."}}
{"actor":{"display_login":"coleifer"}}