You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When selecting multiple columns from a left outer join (optional) i might get a set of 5 optional fields which i want to have in one optional struct that is none if nothing to join.
Describe alternatives you've considered
Alternatives are having all fields optional and writing a huge tuple match to convert into an optional struct or use a helper crate like tuple_combinator
The manual approach would like:
#[derive(FromRow)]structDbRow{id_of_main_table:Uuid,otherstuff:(),//id_of_join:Option<Uuid>,more_joined_stuff:Option<()>,}// some conversion likelet joined = iflet(Some(id_of_join),Some(more_joined_stuff)) = (id_of_join, more_joined_stuff){Some(Joined{
id_of_join,
more_joined_stuff
})}else{None};
I've stumbled upon a series of Option in a query result type and wanted to refactor it into a single flattened Option<Inner> only to realize that this is not supported in sqlx, unlike in serde (playground).
Activity
pravic commentedon Apr 1, 2024
I've stumbled upon a series of
Optionin a query result type and wanted to refactor it into a single flattenedOption<Inner>only to realize that this is not supported insqlx, unlike inserde(playground).But this should be easy, shouldn't it?
enhancement: (transact-rs#2934) implement FromRow for Option<T> where…
transact-rs#2934 solution using autoref trick instead of blanket impl…