{"action":"created","issue":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/47","repository_url":"https://api.github.com/repos/groue/GRDB.swift","labels_url":"https://api.github.com/repos/groue/GRDB.swift/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/groue/GRDB.swift/issues/47/comments","events_url":"https://api.github.com/repos/groue/GRDB.swift/issues/47/events","html_url":"https://github.com/groue/GRDB.swift/issues/47","id":154243926,"number":47,"title":"Generic parameter T could not be inferred (Swift 2.2)","user":{"login":"skreutzberger","id":564725,"avatar_url":"https://avatars.githubusercontent.com/u/564725?v=3","gravatar_id":"","url":"https://api.github.com/users/skreutzberger","html_url":"https://github.com/skreutzberger","followers_url":"https://api.github.com/users/skreutzberger/followers","following_url":"https://api.github.com/users/skreutzberger/following{/other_user}","gists_url":"https://api.github.com/users/skreutzberger/gists{/gist_id}","starred_url":"https://api.github.com/users/skreutzberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skreutzberger/subscriptions","organizations_url":"https://api.github.com/users/skreutzberger/orgs","repos_url":"https://api.github.com/users/skreutzberger/repos","events_url":"https://api.github.com/users/skreutzberger/events{/privacy}","received_events_url":"https://api.github.com/users/skreutzberger/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/groue/GRDB.swift/labels/support","name":"support","color":"A1426D"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-05-11T13:29:52Z","updated_at":"2016-09-03T15:28:24Z","closed_at":"2016-05-11T13:33:07Z","body":"I am using the latest version from master branch on the latest Xcode and database queue creation does work. Now I am stuck with my first execution call which somehow does not want to compile.\r\n\r\nI saw that there was an issue with Swift 2.2 some weeks ago and it was fixed so I don’t know why that error occurs :(\r\n\r\n<img width=\"817\" alt=\"screenshot 2016-05-11 at 15 26 45\" src=\"https://cloud.githubusercontent.com/assets/564725/15182510/2e89bd94-178d-11e6-8a6a-97e71b1456ca.png\">\r\n"},"comment":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/comments/244552730","html_url":"https://github.com/groue/GRDB.swift/issues/47#issuecomment-244552730","issue_url":"https://api.github.com/repos/groue/GRDB.swift/issues/47","id":244552730,"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-09-03T15:28:24Z","updated_at":"2016-09-03T15:28:24Z","body":"**Solution**\r\n\r\nYou may get this error when using DatabaseQueue.inDatabase, DatabasePool.read, or DatabasePool.write:\r\n\r\n```swift\r\n// Generic parameter 'T' could not be inferred\r\nlet x = dbQueue.inDatabase { db in\r\n    let result = String.fetchOne(db, ...)\r\n    return result\r\n}\r\n```\r\n\r\nThis is a Swift compiler issue (see [SR-1570](https://bugs.swift.org/browse/SR-1570)).\r\n\r\nThe general workaround is to explicitly declare the type of the closure result:\r\n\r\n```swift\r\n// General Workaround\r\nlet x = dbQueue.inDatabase { db -> String? in\r\n    let result = String.fetchOne(db, ...)\r\n    return result\r\n}\r\n```\r\n\r\nYou can also, when possible, write a single-line closure:\r\n\r\n```swift\r\n// Single-line closure workaround:\r\nlet x = dbQueue.inDatabase { db in\r\n    String.fetchOne(db, ...)\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"groue"}}