package commontypes // RustTypeMap maps PostgreSQL types to Rust types var RustTypeMap = map[string]string{ // Integer types "integer": "i32", "int": "i32", "int4": "i32", "smallint": "i16", "int2": "i16", "bigint": "i64", "int8": "i64", "serial": "i32", "bigserial": "i64", "smallserial": "i16", // String types "text": "String", "varchar": "String", "char": "String", "character": "String", "citext": "String", "bpchar": "String", "uuid": "String", // Boolean "boolean": "bool", "bool": "bool", // Float types "real": "f32", "float4": "f32", "double precision": "f64", "float8": "f64", "numeric": "f64", "decimal": "f64", // Date/Time types (using chrono crate) "timestamp": "NaiveDateTime", "timestamp without time zone": "NaiveDateTime", "timestamp with time zone": "DateTime", "timestamptz": "DateTime", "date": "NaiveDate", "time": "NaiveTime", "time without time zone": "NaiveTime", "time with time zone": "DateTime", "timetz": "DateTime", // Binary "bytea": "Vec", // JSON "json": "serde_json::Value", "jsonb": "serde_json::Value", } // SQLToRust converts SQL types to Rust types func SQLToRust(sqlType string, nullable bool) string { baseType := ExtractBaseType(sqlType) rustType, ok := RustTypeMap[baseType] if !ok { rustType = "String" } // Handle nullable types with Option if nullable { return rustType } return "Option<" + rustType + ">" }