ormlite icon indicating copy to clipboard operation
ormlite copied to clipboard

derive Clone for Join

Open nitn3lav opened this issue 1 year ago • 2 comments

nitn3lav avatar Feb 15 '24 20:02 nitn3lav

Please note that this will break code like this because calls to clone and to_owned will no longer be dereferenced:

#[derive(Debug, Model)]
struct A {
    id: Uuid,
    #[ormlite(join_column = "b")]
    b: Join<B>
}

#[derive(Clone, Debug, Model)]
struct B {
    id: Uuid,
}

fn hi(a: A) {
    // no longer works
    let x: B = a.b.to_owned();
    // now works
    let y: Join<B> = a.b.to_owned();
    // still works
    let z: B = (*a.b).to_owned();
}

nitn3lav avatar Feb 15 '24 20:02 nitn3lav

Can you provide a rationale and example code for why you'd want to Clone a Join struct? My mental model is that it's owned by the queried object, and never lives elsewhere. Definitely happy to include it if it makes sense, just concerned it might also lead to mistakes where users think they're updating the values, but it was only the clone that was updated.

kurtbuilds avatar Feb 15 '24 21:02 kurtbuilds