{"action":"opened","issue":{"url":"https://api.github.com/repos/diesel-rs/diesel/issues/330","repository_url":"https://api.github.com/repos/diesel-rs/diesel","labels_url":"https://api.github.com/repos/diesel-rs/diesel/issues/330/labels{/name}","comments_url":"https://api.github.com/repos/diesel-rs/diesel/issues/330/comments","events_url":"https://api.github.com/repos/diesel-rs/diesel/issues/330/events","html_url":"https://github.com/diesel-rs/diesel/issues/330","id":154889220,"number":330,"title":" [E0277]: the trait bound `i32: diesel::types::FromSqlRow<diesel::types::Nullable<diesel::types::Integer>, diesel::pg::Pg>` is not satisfied","user":{"login":"fuyingfuying","id":12774287,"avatar_url":"https://avatars.githubusercontent.com/u/12774287?v=3","gravatar_id":"","url":"https://api.github.com/users/fuyingfuying","html_url":"https://github.com/fuyingfuying","followers_url":"https://api.github.com/users/fuyingfuying/followers","following_url":"https://api.github.com/users/fuyingfuying/following{/other_user}","gists_url":"https://api.github.com/users/fuyingfuying/gists{/gist_id}","starred_url":"https://api.github.com/users/fuyingfuying/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fuyingfuying/subscriptions","organizations_url":"https://api.github.com/users/fuyingfuying/orgs","repos_url":"https://api.github.com/users/fuyingfuying/repos","events_url":"https://api.github.com/users/fuyingfuying/events{/privacy}","received_events_url":"https://api.github.com/users/fuyingfuying/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-15T04:10:42Z","updated_at":"2016-05-15T04:10:42Z","closed_at":null,"body":"![2016-05-15 11-48-45](https://cloud.githubusercontent.com/assets/12774287/15271938/e688eef2-1a93-11e6-9198-50a0f7818ef2.png)\r\nHello, when I try to use diesel to build my first orm, and error is come. My way is exactly same  to your getting-start doc.\r\nup.sql:\r\n```sql\r\nCREATE TABLE USERS (\r\n    uid VARCHAR PRIMARY KEY,\r\n    realname VARCHAR NOT NULL,\r\n    age INTEGER,\r\n    sex VARCHAR\r\n);\r\n```\r\n\r\ndown.sql:\r\n\r\n```sql\r\nDROP TABLE USERS;\r\n```\r\n\r\n.env:\r\n\r\n```\r\nDATABASE_URL=postgres://postgres:postgres@localhost/simllsan\r\n```\r\n\r\nand the command `diesel migration redo` has been executed successfully : \r\n\r\n``` bash\r\nfuying@fuying-linux:~/rustprojs/simtraining$ diesel migration redo\r\nRolling back migration 20160514210851\r\nRunning migration 20160514210851\r\n```\r\nlib.rs:\r\n\r\n```rust\r\n#![feature(custom_derive, custom_attribute, plugin)]\r\n#![plugin(serde_macros, diesel_codegen, dotenv_macros)]\r\n\r\n#[macro_use]\r\nextern crate diesel;\r\nextern crate dotenv;\r\n\r\nextern crate serde;\r\nextern crate serde_json;\r\n\r\nextern crate time;\r\nextern crate rand;\r\nextern crate libc;\r\nextern crate mio;\r\n#[cfg(windows)]\r\nextern crate winapi;\r\n#[cfg(windows)]\r\nextern crate ws2_32;\r\n\r\npub mod jizu;\r\npub mod simctrl;\r\npub mod util;\r\npub mod zhiling;\r\npub mod dianzhan;\r\npub mod duanluqi;\r\npub mod fuzai;\r\npub mod node;\r\npub mod zhilu;\r\npub mod xitong;\r\n\r\npub mod schema;\r\npub mod user;\r\n// pub mod evaluation;\r\n// pub mod projects;\r\n// pub mod station;\r\n// pub mod training;\r\nuse diesel::prelude::*;\r\nuse diesel::pg::PgConnection;\r\nuse dotenv::dotenv;\r\nuse std::env;\r\nuse diesel::result::Error;\r\nuse user::{User, NewUser};\r\n\r\npub fn establish_connection() -> PgConnection {\r\n    dotenv().ok();\r\n\r\n    let database_url = env::var(\"DATABASE_URL\")\r\n        .expect(\"DATABASE_URL must be set\");\r\n    PgConnection::establish(&database_url)\r\n        .expect(&format!(\"Error connecting to {}\", database_url))\r\n}\r\n\r\npub fn create_user<'a>(conn: &PgConnection,\r\n                  _uid: &'a str,\r\n                  _realname: &'a str,\r\n                  _age: i32,\r\n                  _sex: &'a str)\r\n                  -> QueryResult<User> {\r\n    use schema::users;\r\n    let uid_s = String::from(_uid);\r\n\r\n    let result = users::table.find(uid_s).first(conn);\r\n    match result {\r\n        Err(NotFound) => {\r\n            let new_user = NewUser {\r\n                uid: _uid,\r\n                realname: _realname,\r\n                age : _age,\r\n                sex : _sex,\r\n            };\r\n            return diesel::insert(&new_user).into(users::table)\r\n                .get_result(conn);\r\n        }\r\n        Ok(_) => return Err(Error::DatabaseError(\"此用户名已存在\".to_string())),\r\n    }\r\n}\r\n\r\n```\r\n\r\nschema.rs:\r\n\r\n```rust\r\ninfer_schema!(dotenv!(\"DATABASE_URL\"));\r\n```\r\n\r\nuser.rs:\r\n\r\n```rust\r\nuse super::schema::users;\r\n#[derive(PartialEq, Copy, Clone, Debug, Serialize, Deserialize)]\r\npub enum Sex {\r\n    Male,\r\n    Female,\r\n    Unisex,\r\n}\r\n#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, Queryable)]\r\npub struct User {\r\n    pub uid: String,\r\n    pub realname: String,\r\n    pub age: i32,\r\n    pub sex: String,\r\n}\r\n\r\n#[insertable_into(users)]\r\npub struct NewUser<'a> {\r\n    pub uid: &'a str,\r\n    pub realname: &'a str,\r\n    pub age: i32,\r\n    pub sex: &'a str,\r\n}\r\n\r\nimpl User {\r\n    pub fn new(_id: &str, _realname: &str) -> User {\r\n        User {\r\n            uid: String::from(_id),\r\n            realname: String::from(_realname),\r\n            age: 0,\r\n            sex: \"\".to_string(),\r\n        }\r\n    }\r\n\r\n}\r\n\r\n```"}}