{"action":"opened","issue":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/128","repository_url":"https://api.github.com/repos/groue/GRDB.swift","labels_url":"https://api.github.com/repos/groue/GRDB.swift/issues/128/labels{/name}","comments_url":"https://api.github.com/repos/groue/GRDB.swift/issues/128/comments","events_url":"https://api.github.com/repos/groue/GRDB.swift/issues/128/events","html_url":"https://github.com/groue/GRDB.swift/issues/128","id":179152554,"number":128,"title":"Crash on \"","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":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-26T06:58:44Z","updated_at":"2016-09-26T06:58:44Z","closed_at":null,"body":"The framework seems to internally use `try!` when executing statements which lead to a hard crash if the query is not perfect. A big No-No for Swift which should never crash in front of a user.\r\n\r\nAnyway, here is what happens:\r\nMy user enters astring in the front end and I am using that string as value for one of the `StatementArguments`.\r\n\r\nThe crash occurs now at `Row.fetch` the call:\r\n```Swift\r\n db.inDatabase { db in\r\n            for row in Row.fetch(db, sql, arguments: StatementArguments(args)) {\r\n```\r\n\r\nHere is the crash output from console when I search for `foo \"`:\r\n```\r\nfatal error: 'try!' expression unexpectedly raised an error: SQLite error 1 with statement ` SELECT e.id, e.deviceID, e.level, e.appVersion, e.appBuild, e.session, e.thread, e.fileName, e.function, e.line, e.timestamp, e.status, messages.message, devices.uuid, devices.userName FROM entries as e INNER JOIN messages ON e.id = messages.id INNER JOIN devices ON e.deviceID = devices.id WHERE e.timestamp < 4102358400.0 AND messages.message MATCH :message ORDER BY e.timestamp DESC LIMIT 50` arguments [message:\"foo \\\"\"]: malformed MATCH expression: [foo \"]: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.46.2/src/swift/stdlib/public/core/ErrorType.swift, line 178\r\n2016-09-26 08:52:09.382465 SwiftyBeaver[56385:2104611] fatal error: 'try!' expression unexpectedly raised an error: SQLite error 1 with statement ` SELECT e.id, e.deviceID, e.level, e.appVersion, e.appBuild, e.session, e.thread, e.fileName, e.function, e.line, e.timestamp, e.status, messages.message, devices.uuid, devices.userName FROM entries as e INNER JOIN messages ON e.id = messages.id INNER JOIN devices ON e.deviceID = devices.id WHERE e.timestamp < 4102358400.0 AND messages.message MATCH :message ORDER BY e.timestamp DESC LIMIT 50` arguments [message:\"foo \\\"\"]: malformed MATCH expression: [foo \"]: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.46.2/src/swift/stdlib/public/core/ErrorType.swift, line 178\r\n```\r\n\r\nThe crash occurs even if I wrap the `\"` into a `\\\\\\\"`. Something else Xcode does not allow me to do. How can I fix it or better: can GRDB stop using `try!`?"}}
{"actor":{"display_login":"skreutzberger"}}