New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerSide wrapper #1291

Closed
hgrecco opened this Issue Nov 3, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@hgrecco

hgrecco commented Nov 3, 2017

Is there a way to implement a (let's call it) ServerSide object (similar to Option) to tell diesel that a particular field should be ignored from any insert/update?

The example from the guide would then become:

#[derive(Queryable, Insertable)]
pub struct Post {
    pub id: ServerSide<i32>,
    pub title: String,
    pub body: String,
    pub published: bool,
}

and then use it in insert as:

    let new_post = NewPost {
        id: None // Or another special value
        title: title,
        body: body,
        published: false
    };

    diesel::insert(&new_post).into(posts::table)
        .get_result(conn)
        .expect("Error saving new post")

The same could be applied to other fields like created_at and updated_at.

See also: #860 and this reddit discussion

@killercup

This comment has been minimized.

Member

killercup commented Nov 3, 2017

@sgrif

This comment has been minimized.

Member

sgrif commented Jan 8, 2018

Yeah this seems like a duplicate of #860 to me.

@sgrif sgrif closed this Jan 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment