Skip to main content

FromQueryResult

Derive Macro FromQueryResult 

Source
#[derive(FromQueryResult)]
{
    // Attributes available to this derive:
    #[column]
}
Expand description

Derive macro: auto-generates an sz_orm_core::FromQueryResult trait impl.

Deserializes from a query result row (HashMap<String, Value>) into a struct instance. Option<T> fields automatically return None when the column is missing or the value is NULL.

§Supported attributes

  • #[column(name = "...")] — overrides the column name mapping (defaults to the field name)

§Example

use sz_orm_macros::FromQueryResult;

#[derive(FromQueryResult)]
struct UserRow {
    id: i64,
    name: String,
    #[column(name = "user_email")]
    email: Option<String>,
}