-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I have found these related issues/pull requests
Description
For queries that return a subset of a struct's fields, query_as can't be used and the user has to call query and then manually move each of the fields into the struct.
Prefered solution
It'd be nice to have something like query_as_builder!(expr, query, ...args) that expands to expr.field1(value1).field2(value2) instead of Type {field1: value1, field2: value2}. With typesafe builders like bon this would still provide type safety, while allowing users to just populate the remaining required fields on the builder themselves. It could have the following variantes:
query_as_builder!(builder_expr, "SQL", args...)- Checked queryquery_as_builder_unchecked!(...)- Unchecked variantquery_file_as_builder!(...)- Load SQL from filequery_file_as_builder_unchecked!(...)- Unchecked file variant
I made a standalone implementation of this that manipulates the macro output from query!, if this feature isn't appropriate for the main sqlx crate then I'd probably publish it under sqlx-query-as-builder.
Is this a breaking change? Why or why not?
Not breaking, new feature.