Skip to content

Specify output for query_as! #1646

Answered by abonander
Burny-McBurnFace asked this question in Q&A
Discussion options

You must be logged in to vote

query_as! supports the same type override syntax as query!: https://docs.rs/sqlx/latest/sqlx/macro.query.html#type-overrides-output-columns

You can also use foo as "foo: _" to have the type inferred from the corresponding field in the struct (it'll still be checked for compatibility at runtime).

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by abonander
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1638 on January 21, 2022 21:58.