{"action":"created","issue":{"url":"https://api.github.com/repos/sgrif/diesel/issues/26","labels_url":"https://api.github.com/repos/sgrif/diesel/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/sgrif/diesel/issues/26/comments","events_url":"https://api.github.com/repos/sgrif/diesel/issues/26/events","html_url":"https://github.com/sgrif/diesel/issues/26","id":119325635,"number":26,"title":"Clarification on `update`","user":{"login":"mcasper","id":6878025,"avatar_url":"https://avatars.githubusercontent.com/u/6878025?v=3","gravatar_id":"","url":"https://api.github.com/users/mcasper","html_url":"https://github.com/mcasper","followers_url":"https://api.github.com/users/mcasper/followers","following_url":"https://api.github.com/users/mcasper/following{/other_user}","gists_url":"https://api.github.com/users/mcasper/gists{/gist_id}","starred_url":"https://api.github.com/users/mcasper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcasper/subscriptions","organizations_url":"https://api.github.com/users/mcasper/orgs","repos_url":"https://api.github.com/users/mcasper/repos","events_url":"https://api.github.com/users/mcasper/events{/privacy}","received_events_url":"https://api.github.com/users/mcasper/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sgrif/diesel/labels/discussion%20desired","name":"discussion desired","color":"bfd4f2"},{"url":"https://api.github.com/repos/sgrif/diesel/labels/hole%20in%20api","name":"hole in api","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/sgrif/diesel/milestones/3","html_url":"https://github.com/sgrif/diesel/milestones/0.3","labels_url":"https://api.github.com/repos/sgrif/diesel/milestones/3/labels","id":1434269,"number":3,"title":"0.3","description":"","creator":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":1,"state":"open","created_at":"2015-11-30T00:45:02Z","updated_at":"2015-11-30T16:26:06Z","due_on":"2015-12-14T07:00:00Z","closed_at":null},"comments":18,"created_at":"2015-11-29T00:07:18Z","updated_at":"2015-12-04T15:44:18Z","closed_at":null,"body":"So far `update` is the hardest to wrap my head around, and I was hoping for some clarification/guidance.\r\n\r\nIn the context of an HTTP API, with a users table that looks like:\r\n```Rust\r\ntable! {\r\n    users {\r\n        id -> Serial,\r\n        first_name -> VarChar,\r\n        last_name -> VarChar,\r\n        email -> VarChar,\r\n    }\r\n}\r\n```\r\nhow would you go about implementing a Users#update action?\r\n\r\nMy first instinct is to have something like:\r\n```Rust\r\n#[changeset_for(users)]\r\npub struct UserChanges {\r\n    id: i32,\r\n    first_name: Option<String>,\r\n    last_name: Option<String>,\r\n    email: Option<String>,\r\n}\r\n\r\nfn update(req: SomeHTTPReq) -> SomeHTTPRes {\r\n  let changeset = UserChanges {\r\n    first_name: req.body.get(\"first_name\"),\r\n    // etc\r\n  }\r\n\r\n  changeset.save_changes(&connection)\r\n}\r\n```\r\nSuch that you end up updating whatever valid params the user sends, but that requires having `Nullable` columns in the table macro, when the columns aren't actually nullable.\r\n\r\nKeep up all the great work!"},"comment":{"url":"https://api.github.com/repos/sgrif/diesel/issues/comments/162000025","html_url":"https://github.com/sgrif/diesel/issues/26#issuecomment-162000025","issue_url":"https://api.github.com/repos/sgrif/diesel/issues/26","id":162000025,"user":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T15:44:18Z","updated_at":"2015-12-04T15:44:18Z","body":"I'm going to change the behavior of `changeset_for` to treat `None` as skip by default in 0.3. The more I think about it, the more clear it becomes that assigning null is not the majority case. You can still set null by manually doing `set(column.eq(None))`.\r\n\r\nI will likely introduce an additional type in the future to represent wanting to assign null (which when deserializing from JSON will require the key being present, and the value being `null`)"}}