{"action":"created","issue":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/61","repository_url":"https://api.github.com/repos/groue/GRDB.swift","labels_url":"https://api.github.com/repos/groue/GRDB.swift/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/groue/GRDB.swift/issues/61/comments","events_url":"https://api.github.com/repos/groue/GRDB.swift/issues/61/events","html_url":"https://github.com/groue/GRDB.swift/issues/61","id":157254168,"number":61,"title":"Savepoint support","user":{"login":"swiftlyfalling","id":18540905,"avatar_url":"https://avatars.githubusercontent.com/u/18540905?v=3","gravatar_id":"","url":"https://api.github.com/users/swiftlyfalling","html_url":"https://github.com/swiftlyfalling","followers_url":"https://api.github.com/users/swiftlyfalling/followers","following_url":"https://api.github.com/users/swiftlyfalling/following{/other_user}","gists_url":"https://api.github.com/users/swiftlyfalling/gists{/gist_id}","starred_url":"https://api.github.com/users/swiftlyfalling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swiftlyfalling/subscriptions","organizations_url":"https://api.github.com/users/swiftlyfalling/orgs","repos_url":"https://api.github.com/users/swiftlyfalling/repos","events_url":"https://api.github.com/users/swiftlyfalling/events{/privacy}","received_events_url":"https://api.github.com/users/swiftlyfalling/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/groue/GRDB.swift/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-27T17:24:27Z","updated_at":"2016-05-28T09:24:32Z","closed_at":null,"body":"What are your thoughts on adding support for [SAVEPOINT](https://www.sqlite.org/lang_savepoint.html) within Transactions?\r\n\r\nPerhaps something like:\r\n\r\n```\r\ntry dbPool.writeInTransaction { db in\r\n    try db.inSavepoint(name: \"Savepoint1\") { \r\n        if let poi = PointOfInterest.fetchOne(db, key: 1) {\r\n            try poi.delete(db) //\r\n        }\r\n        let wine = Wine(color: .Red, name: \"Pomerol\")\r\n        try wine.insert(db)    // need to rollback the delete above if this fails\r\n        return .Commit         // (or .Release?)\r\n    }\r\n    // other SavePoints, etc...\r\n    return .Commit\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/comments/222299193","html_url":"https://github.com/groue/GRDB.swift/issues/61#issuecomment-222299193","issue_url":"https://api.github.com/repos/groue/GRDB.swift/issues/61","id":222299193,"user":{"login":"groue","id":54219,"avatar_url":"https://avatars.githubusercontent.com/u/54219?v=3","gravatar_id":"","url":"https://api.github.com/users/groue","html_url":"https://github.com/groue","followers_url":"https://api.github.com/users/groue/followers","following_url":"https://api.github.com/users/groue/following{/other_user}","gists_url":"https://api.github.com/users/groue/gists{/gist_id}","starred_url":"https://api.github.com/users/groue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/groue/subscriptions","organizations_url":"https://api.github.com/users/groue/orgs","repos_url":"https://api.github.com/users/groue/repos","events_url":"https://api.github.com/users/groue/events{/privacy}","received_events_url":"https://api.github.com/users/groue/received_events","type":"User","site_admin":false},"created_at":"2016-05-28T09:24:32Z","updated_at":"2016-05-28T09:24:32Z","body":"Note to myself on how to provide robust support for savepoints even when user executes raw SQL statements and does not use high-level APIs: savepoints statements can be identified by [StatementCompilationObserver](https://github.com/groue/GRDB.swift/blob/v0.67.0/GRDB/Core/Database.swift#L955):\r\n\r\n- `SAVEPOINT foo` has code [SQLITE_SAVEPOINT](https://www.sqlite.org/c3ref/c_alter_table.html), first string `BEGIN`, and second string `foo`.\r\n- `ROLLBACK TO SAVEPOINT foo` has code SQLITE_SAVEPOINT, first string `ROLLBACK`, and second string `foo`.\r\n- `RELEASE SAVEPOINT foo` has code SQLITE_SAVEPOINT, first string `RELEASE`, and second string `foo`."}}
{"actor":{"display_login":"groue"}}