{"action":"created","issue":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/82","repository_url":"https://api.github.com/repos/groue/GRDB.swift","labels_url":"https://api.github.com/repos/groue/GRDB.swift/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/groue/GRDB.swift/issues/82/comments","events_url":"https://api.github.com/repos/groue/GRDB.swift/issues/82/events","html_url":"https://github.com/groue/GRDB.swift/issues/82","id":164830035,"number":82,"title":"RTree issue","user":{"login":"hdlj","id":8809355,"avatar_url":"https://avatars.githubusercontent.com/u/8809355?v=3","gravatar_id":"","url":"https://api.github.com/users/hdlj","html_url":"https://github.com/hdlj","followers_url":"https://api.github.com/users/hdlj/followers","following_url":"https://api.github.com/users/hdlj/following{/other_user}","gists_url":"https://api.github.com/users/hdlj/gists{/gist_id}","starred_url":"https://api.github.com/users/hdlj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hdlj/subscriptions","organizations_url":"https://api.github.com/users/hdlj/orgs","repos_url":"https://api.github.com/users/hdlj/repos","events_url":"https://api.github.com/users/hdlj/events{/privacy}","received_events_url":"https://api.github.com/users/hdlj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-11T12:54:03Z","updated_at":"2016-07-12T09:52:45Z","closed_at":null,"body":"Hello groue,\r\n\r\nI have the same kind of issue as #80 but with the Rtree. When a read is done on a Rtree, database issue events. \r\n\r\nThe same precondition fails: \r\n```\r\nGRDBPrecondition(observer.databaseEventKinds.isEmpty, \"Invalid statement type for query \\(String(reflecting: sql)): use UpdateStatement instead.\")\r\n```\r\n\r\nHere some code to reproduce it:\r\n\r\n```\r\nmigrator.registerMigration(\"rtree\") { db in\r\n            try db.execute(\"CREATE VIRTUAL TABLE geolocation_rtree USING rtree(object_id, minX, maxX, minY, maxY);\")\r\n        }\r\n```\r\n```\r\ntry! db.writeInTransaction { db in\r\n            let insertStatement = \"INSERT OR REPLACE INTO geolocation_rtree (object_id, minX, maxX, minY, maxY) VALUES(?,?,?,?,?)\"\r\n            try! db.execute(insertStatement, arguments: [1, 2.0, 2.0, 3.0, 3.0])\r\n            try! db.execute(insertStatement, arguments: [2, 2.1, 2.1, 3.0, 3.0])\r\n            try! db.execute(insertStatement, arguments: [3, 2.2, 2.2, 3.1, 3.1])\r\n            try! db.execute(insertStatement, arguments: [4, 2.1, 2.2, 3.4, 3.5])\r\n            try! db.execute(insertStatement, arguments: [5, 2.0, 2.1, 3.2, 3.3])\r\n            try! db.execute(insertStatement, arguments: [6, 2.5, 2.6, 3.2, 3.3])\r\n            try! db.execute(insertStatement, arguments: [7, 2.2, 2.4, 3.1, 3.1])\r\n            return .Commit\r\n        }\r\n```\r\n\r\n```\r\nlet points = try! db.read { db in\r\n            return Row.fetchAll(db, \"SELECT * FROM geolocation_rtree WHERE minX >= ? AND maxX <= ? AND minY >= ? AND maxY <= ? \", arguments: [2.0, 2.1, 3.2, 3.3], adapter: nil)\r\n        }\r\n```\r\n\r\nThe database receives this events which fails the precondition: \r\n\r\n```\r\nInsert(\"geolocation_rtree_node\")\r\nDelete(\"geolocation_rtree_node\")\r\nInsert(\"geolocation_rtree_rowid\")\r\nDelete(\"geolocation_rtree_rowid\")\r\nInsert(\"geolocation_rtree_parent\")\r\nDelete(\"geolocation_rtree_parent\")\r\n```\r\n\r\nShould I use a write transaction or is it possible to do it in a read block ? \r\n\r\nThanks in advance for your answers!"},"comment":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/comments/231992620","html_url":"https://github.com/groue/GRDB.swift/issues/82#issuecomment-231992620","issue_url":"https://api.github.com/repos/groue/GRDB.swift/issues/82","id":231992620,"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-07-12T09:52:45Z","updated_at":"2016-07-12T09:52:45Z","body":"Hmmm. I'm in vacation now, so I won't be able to answer your issue until next week. Meanwhile can you downgrade to v0.72.0?"}}
{"actor":{"display_login":"groue"}}