{"action":"created","issue":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/1014","repository_url":"https://api.github.com/repos/typeorm/typeorm","labels_url":"https://api.github.com/repos/typeorm/typeorm/issues/1014/labels{/name}","comments_url":"https://api.github.com/repos/typeorm/typeorm/issues/1014/comments","events_url":"https://api.github.com/repos/typeorm/typeorm/issues/1014/events","html_url":"https://github.com/typeorm/typeorm/issues/1014","id":264370898,"number":1014,"title":"Transaction doesn't rollback","user":{"login":"emorris00","id":6057037,"avatar_url":"https://avatars0.githubusercontent.com/u/6057037?v=4","gravatar_id":"","url":"https://api.github.com/users/emorris00","html_url":"https://github.com/emorris00","followers_url":"https://api.github.com/users/emorris00/followers","following_url":"https://api.github.com/users/emorris00/following{/other_user}","gists_url":"https://api.github.com/users/emorris00/gists{/gist_id}","starred_url":"https://api.github.com/users/emorris00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emorris00/subscriptions","organizations_url":"https://api.github.com/users/emorris00/orgs","repos_url":"https://api.github.com/users/emorris00/repos","events_url":"https://api.github.com/users/emorris00/events{/privacy}","received_events_url":"https://api.github.com/users/emorris00/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-10-10T20:47:58Z","updated_at":"2017-10-11T19:11:29Z","closed_at":null,"author_association":"NONE","body":"Version: 0.0.11\r\n\r\nThe \"Database entity is not set for the given subject\" error does not rollback transactions\r\n```javascript\r\n// this will remove row with id 1 but not id 2\r\nrepository.transaction(async repository=> {\r\n    repository.remove({id: 1})\r\n    repository.remove({}) // errors out here, but also commits transaction\r\n    repository.remove({id: 2})\r\n})\r\n```"},"comment":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/comments/335916865","html_url":"https://github.com/typeorm/typeorm/issues/1014#issuecomment-335916865","issue_url":"https://api.github.com/repos/typeorm/typeorm/issues/1014","id":335916865,"user":{"login":"emorris00","id":6057037,"avatar_url":"https://avatars0.githubusercontent.com/u/6057037?v=4","gravatar_id":"","url":"https://api.github.com/users/emorris00","html_url":"https://github.com/emorris00","followers_url":"https://api.github.com/users/emorris00/followers","following_url":"https://api.github.com/users/emorris00/following{/other_user}","gists_url":"https://api.github.com/users/emorris00/gists{/gist_id}","starred_url":"https://api.github.com/users/emorris00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emorris00/subscriptions","organizations_url":"https://api.github.com/users/emorris00/orgs","repos_url":"https://api.github.com/users/emorris00/repos","events_url":"https://api.github.com/users/emorris00/events{/privacy}","received_events_url":"https://api.github.com/users/emorris00/received_events","type":"User","site_admin":false},"created_at":"2017-10-11T19:11:29Z","updated_at":"2017-10-11T19:11:29Z","author_association":"NONE","body":"Ah sorry, apparently I didn't understand my problem. It appears that the problem is with using Promise.all, though now I'm not sure if its a bug or not. Let me know what you think. This is using version 0.1.0\r\n\r\n```javascript\r\nimport {createConnection, getConnection, Connection, Entity, PrimaryColumn} from 'typeorm'\r\n\r\n\r\n@Entity()\r\nclass TestEntity {\r\n    @PrimaryColumn({type: \"int\"})\r\n    id: number\r\n}\r\n\r\n// transaction should throw and not delete the row\r\n// passes\r\nasync function test1() {\r\n    let connection = getConnection()\r\n    await connection.manager.save(TestEntity, {id: 1})\r\n\r\n    console.assert(await connection.manager.findOneById(TestEntity, 1), \"row doesn't exist before transaction\")\r\n    \r\n    let didThrow = false\r\n    try {\r\n        await connection.transaction(async manager => {\r\n            await manager.remove(TestEntity, {id: 1})\r\n            await new Promise((resolve, reject) => reject('reject'))\r\n        })\r\n    }\r\n    catch(e) {\r\n        didThrow = true\r\n    }\r\n\r\n    console.assert(didThrow, \"transaction didn't throw\")\r\n    console.assert(await connection.manager.findOneById(TestEntity, 1), \"row doesn't exist after transaction\")\r\n}\r\n\r\n// transaction should throw and not delete the row\r\n// fails, row gets deleted\r\nasync function test2() {\r\n    let connection = getConnection()\r\n    await connection.manager.save(TestEntity, {id: 1})\r\n\r\n    console.assert(await connection.manager.findOneById(TestEntity, 1), \"row doesn't exist before transaction\")\r\n\r\n    let didThrow = false\r\n    try {\r\n        await connection.transaction(async manager => {\r\n            await Promise.all([\r\n                manager.remove(TestEntity, {id: 1}),\r\n                new Promise((resolve, reject) => reject('reject')),\r\n            ])\r\n        })\r\n    }\r\n    catch(e) {\r\n        didThrow = true\r\n    }\r\n\r\n    console.assert(didThrow, \"transaction didn't throw\")\r\n    console.assert(await connection.manager.findOneById(TestEntity, 1), \"row doesn't exist after transaction\")\r\n}\r\n\r\n\r\nasync function runTest(func: Function) {\r\n    try {\r\n        await func()\r\n        console.log(`${func.name} passed`)\r\n    }\r\n    catch(e) {\r\n        console.log(`${func.name} failed,`, e.message)\r\n    }\r\n}\r\n\r\n\r\ncreateConnection({\r\n    type: \"mysql\",\r\n    host: \"localhost\",\r\n    port: 3306,\r\n    username: \"root\",\r\n    password: \"Q48geH6TMguuDbXaKQeO\",\r\n    database: \"test\",\r\n    entities: [TestEntity],\r\n    synchronize: true,\r\n}).then(async connection => {\r\n    await runTest(test1)\r\n    await runTest(test2)\r\n    process.exit()\r\n})\r\n```"}}
{"actor":{"display_login":"emorris00"}}