modelstruct 0.1.0

A Rust crate that provides a derive macro Model to automatically generate SQL CREATE TABLE IF NOT EXISTS statements from struct definitions.
Documentation
use modelstruct::Model;

#[derive(Model)]
struct TestUser {
    id: i32,
    name: String,
    email: Option<String>,
    age: Option<i32>,
    is_active: bool,
}

#[test]
fn test_model_derivation() {
    let sql = TestUser::create_table_sql();
    let expected = "CREATE TABLE IF NOT EXISTS testuser (\n    id INTEGER,\n    name TEXT,\n    email TEXT NULL,\n    age INTEGER NULL,\n    is_active BOOLEAN\n);";
    
    assert_eq!(sql, expected);
    assert_eq!(TestUser::table_name(), "testuser");
}

#[test]
fn test_supported_types() {
    #[derive(Model)]
    struct AllTypes {
        int32: i32,
        int64: i64,
        uint32: u32,
        uint64: u64,
        float32: f32,
        float64: f64,
        boolean: bool,
        string: String,
        optional_int: Option<i32>,
        optional_string: Option<String>,
    }
    
    let sql = AllTypes::create_table_sql();
    assert!(sql.contains("int32 INTEGER"));
    assert!(sql.contains("int64 BIGINT"));
    assert!(sql.contains("uint32 INTEGER"));
    assert!(sql.contains("uint64 BIGINT"));
    assert!(sql.contains("float32 REAL"));
    assert!(sql.contains("float64 REAL"));
    assert!(sql.contains("boolean BOOLEAN"));
    assert!(sql.contains("string TEXT"));
    assert!(sql.contains("optional_int INTEGER NULL"));
    assert!(sql.contains("optional_string TEXT NULL"));
}