macro_rules! tracked {
($ty:ident { $($field:ident : $value:expr),* $(,)? }) => { ... };
($ty:ident { $($field:ident : $value:expr),* , .. $rest:expr $(,)? }) => { ... };
}Expand description
Wrap a model struct literal and track which fields were explicitly provided.
This is the Rust equivalent of Pydantic’s “fields_set” tracking and enables
correct exclude_unset behavior for dumps via TrackedModel::sql_model_dump().
Examples:
ⓘ
use sqlmodel::tracked;
let user = tracked!(User {
id: 1,
name: "Alice".to_string(),
..Default::default()
});
// Omits fields that came from defaults, keeps explicitly provided fields.
let json = user.sql_model_dump(DumpOptions::default().exclude_unset())?;