Closed SpartanPlume closed 2 months ago
This is fixed in a newly cut version, 0.19.
See the test 06-insert.rs for usage, copied here:
#[derive(Model)]
#[ormlite(insert = "InsertUser")]
// Note the previous syntax, #[ormlite(insertable = InsertUser)] still works, but the new syntax is preferred.
pub struct User {
id: i32,
name: String,
#[ormlite(default)]
secret: Option<String>,
#[ormlite(default_value = "5")]
number: i32,
#[ormlite(column = "type")]
ty: i32,
#[ormlite(join_column = "org_id")]
organization: Join<Organization>,
}
#[derive(Insert)]
#[ormlite(returns = "User")]
pub struct InsertUser2 {
name: String,
number: i32,
#[ormlite(column = "type")]
ty: i32,
org_id: i32,
}
Released as 0.19 because I batched some other updates, upgrading to sqlx 0.8, among other updates.
I'll mark as resolved, but feel free to respond and/or open a new issue if you still run into issues.
Thanks for the new version, it works perfectly.
When using the
insert
function on a separate insertion struct, it returns the insertion struct instead of the original struct.Dependencies:
Working case without separate insertion struct:
Non-working case with separate insertion struct:
Error:
It doesn't seem expected that the behaviour is different between the 2 ways of having insertion struct.