Skip to main content

FromPartialPgRow

Trait FromPartialPgRow 

Source
pub trait FromPartialPgRow: Sized {
    // Required method
    fn decode_partial_pg_row(
        row: &PgRow,
        selected: &[&str],
    ) -> Result<Self, Error>;
}
Expand description

Companion to sqlx::FromRow that decodes a row projected by .select(...) — i.e. a row where only the named columns are present in the SQL SELECT list. Non-selected fields populate to their type’s Default::default() value.

The macro emits this impl for every generated model struct, so the trait is invisible to schema authors at the call site; it shows up as the bound on the typed builder’s T generic.

Required Methods§

Source

fn decode_partial_pg_row(row: &PgRow, selected: &[&str]) -> Result<Self, Error>

Decode row into Self using selected as the projection manifest. selected carries the SQL column names (snake_case) the caller asked for; any column not in this list falls through to Default::default().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§