use super::support::{from_tables, required};
use crate::generators::rust::types;
const UNSUPPORTED: [&str; 1] = ["sqlx::types::BigDecimal"];
fn map(sql_type: &str) -> types::Mapping {
types::map(&required("value", sql_type), &from_tables(Vec::new()))
}
#[test]
fn no_generated_type_is_one_utoipa_cannot_schema() {
let sql_types = [
"smallint",
"integer",
"bigint",
"boolean",
"real",
"double precision",
"numeric(12,2)",
"decimal",
"money",
"uuid",
"json",
"jsonb",
"bytea",
"date",
"time",
"timestamp",
"timestamp with time zone",
"text",
"character varying(255)",
"geography(Point,4326)",
];
for sql_type in sql_types {
let mapped = map(sql_type);
assert!(
!UNSUPPORTED.contains(&mapped.rust.as_str()),
"{sql_type} maps to {}, which has no utoipa schema",
mapped.rust
);
}
}
#[test]
fn an_exact_decimal_still_declares_a_ts_override() {
for sql_type in ["numeric(12,2)", "decimal", "money"] {
assert_eq!(
map(sql_type).ts,
Some("string"),
"{sql_type} lost its ts override"
);
}
}