Skip to content

Result type for single column query #140

Answered by fernandobatels
zhus asked this question in Q&A
Discussion options

You must be logged in to vote

(i32) is not a tuple, you need use a extra , when you have a single column to force a tuple:

let rows: Vec<(i32,)> = conn.query("select 1+1 from RDB$DATABASE", ())?;

You can also use the query_first if you only need one row:

let (sum,): (i32,) = conn.query_first("select 1+1 from RDB$DATABASE", ())?.unwrap();

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zhus
Comment options

Answer selected by zhus
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