{"action":"created","issue":{"url":"https://api.github.com/repos/blackbeam/rust-mysql-simple/issues/79","repository_url":"https://api.github.com/repos/blackbeam/rust-mysql-simple","labels_url":"https://api.github.com/repos/blackbeam/rust-mysql-simple/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/blackbeam/rust-mysql-simple/issues/79/comments","events_url":"https://api.github.com/repos/blackbeam/rust-mysql-simple/issues/79/events","html_url":"https://github.com/blackbeam/rust-mysql-simple/issues/79","id":189438124,"number":79,"title":"Some(NULL) Should Be Convert to None or Some Default Value","user":{"login":"asteriskTheServer","id":21181189,"avatar_url":"https://avatars.githubusercontent.com/u/21181189?v=3","gravatar_id":"","url":"https://api.github.com/users/asteriskTheServer","html_url":"https://github.com/asteriskTheServer","followers_url":"https://api.github.com/users/asteriskTheServer/followers","following_url":"https://api.github.com/users/asteriskTheServer/following{/other_user}","gists_url":"https://api.github.com/users/asteriskTheServer/gists{/gist_id}","starred_url":"https://api.github.com/users/asteriskTheServer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asteriskTheServer/subscriptions","organizations_url":"https://api.github.com/users/asteriskTheServer/orgs","repos_url":"https://api.github.com/users/asteriskTheServer/repos","events_url":"https://api.github.com/users/asteriskTheServer/events{/privacy}","received_events_url":"https://api.github.com/users/asteriskTheServer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-15T16:22:40Z","updated_at":"2016-11-15T21:20:13Z","closed_at":"2016-11-15T16:56:21Z","body":" I can see see this being fairly useful unless of coarse I am missing some feature in the library which makes this easy already and I haven't found it. \r\n\r\nThe main issue I am facing is the when one does row.take on mysql row where the value is `Some(NULL)` it tries to bind it to some type be it a String or a i32 or whatever data type and will produce the error  `Could not retrieve <type> for value ` which makes sense from the code's perspective, but in terms of usability I don't think this makes sense. If I have a NULL it should be the rust's loose equivalent of a NULL, namely None. Of coarse if I am misunderstanding the why here please let me know. "},"comment":{"url":"https://api.github.com/repos/blackbeam/rust-mysql-simple/issues/comments/260771903","html_url":"https://github.com/blackbeam/rust-mysql-simple/issues/79#issuecomment-260771903","issue_url":"https://api.github.com/repos/blackbeam/rust-mysql-simple/issues/79","id":260771903,"user":{"login":"blackbeam","id":155883,"avatar_url":"https://avatars.githubusercontent.com/u/155883?v=3","gravatar_id":"","url":"https://api.github.com/users/blackbeam","html_url":"https://github.com/blackbeam","followers_url":"https://api.github.com/users/blackbeam/followers","following_url":"https://api.github.com/users/blackbeam/following{/other_user}","gists_url":"https://api.github.com/users/blackbeam/gists{/gist_id}","starred_url":"https://api.github.com/users/blackbeam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blackbeam/subscriptions","organizations_url":"https://api.github.com/users/blackbeam/orgs","repos_url":"https://api.github.com/users/blackbeam/repos","events_url":"https://api.github.com/users/blackbeam/events{/privacy}","received_events_url":"https://api.github.com/users/blackbeam/received_events","type":"User","site_admin":false},"created_at":"2016-11-15T21:20:13Z","updated_at":"2016-11-15T21:20:13Z","body":"This should work:\r\n```rust\r\nPerson {\r\n    // ...\r\n    nickname: row.take(\"nickname\").unwrap(),\r\n}\r\n```\r\n\r\nLet's make it clear:\r\n\r\nYour nickname column value could be NULL, so corresponding rust type for nickname column value is `Option<String>`.\r\n\r\n`Row::take` signature is `fn<T, A>(&mut self, A) -> Option<T>`. `T` in this signature is the type of a column value, and `Option` in return type representing the fact that column value could be already taken from row (which is usually obvious so it's almost always safe to `unwrap` it immediately).\r\n\r\nSo your call to `row.take` should look like this `row.take::<Option<String>, _>(\"nickname\").unwrap()` but in your case compiler can infer the type for `T` so you can just write `nickname: row.take(\"nickname\").unwrap()`"}}
{"actor":{"display_login":"blackbeam"}}