turbosql icon indicating copy to clipboard operation
turbosql copied to clipboard

type aliases unsupported

Open maxomatic458 opened this issue 10 months ago • 1 comments

the following example will not store the data correctly

type StringType = String;
type Number = i64;


#[derive(Turbosql, Default)]
struct Person {
    rowid: Option<i64>,
    name: Option<StringType>,
    age: Option<Number>,
    image_jpg: Option<Vec<u8>>
}

fn main() -> Result<(), Box<dyn std::error::Error>> {

    let name = "Joe";

    let rowid = Person {
        name: Some(name.to_string()),
        age: Some(42),
        ..Default::default()
    }.insert()?;

    Ok(())
}

the name will be stored as the name, but inside quotation marks the age will be stored as regular text

when trying to query the database for a name, it will not find a match, because it is stored with quotation marks

without type aliases everything works fine

maxomatic458 avatar Oct 13 '23 15:10 maxomatic458