Context
This is a lower-priority architectural limitation.
Problem
Projection expressions are not connected to the result model's field types:
#[derive(dbkit::sqlx::FromRow)]
struct ResultRow {
note: String,
}
let rows: Vec<ResultRow> = NullableRow::query()
.select_only()
.column_as(NullableRow::note, "note") // Option<String>
.into_model()
.all(&db)
.await?;
This compiles and fails only if SQLx decodes a NULL value.
Partial mutation results have a related problem. Insert<FullModel> and Update<FullModel> retain Out = FullModel after .returning(vec![...]), even if only one column is returned. Executing the query then attempts to decode a partial row as the complete model.
Desired direction
- Make selected/returned result shapes explicit in the type system where practical.
- At minimum, partial
RETURNING should not continue to claim that it returns the full model.
- If arbitrary projections remain an explicit SQLx decoding boundary, make that boundary clear in the API and documentation.
- Preserve an ergonomic escape hatch for custom
FromRow projection types.
The implementation direction needs design work; this issue tracks the contract rather than prescribing a large type-level query builder.
Context
This is a lower-priority architectural limitation.
Problem
Projection expressions are not connected to the result model's field types:
This compiles and fails only if SQLx decodes a
NULLvalue.Partial mutation results have a related problem.
Insert<FullModel>andUpdate<FullModel>retainOut = FullModelafter.returning(vec![...]), even if only one column is returned. Executing the query then attempts to decode a partial row as the complete model.Desired direction
RETURNINGshould not continue to claim that it returns the full model.FromRowprojection types.The implementation direction needs design work; this issue tracks the contract rather than prescribing a large type-level query builder.