Replies: 1 comment
-
Hi.
In case if a cell value was already taken — the behavior here is similar to the let row: Row = "SELECT 'cell_value' as `cell_name`".first(&mut conn).await?.expect("a single row will be here");
let cell_value = row.take("cell_name").expect("no panic here because the value of the cell `cell_name` is in the row");
let cell_value2 = row.take("cell").expect("this line will panic because the value of the call `cell_name` was taken at the previous line");
For the same reason as described above this should be: let qualifying: Option<Option<u32>> = row.take("isQualifying");
// or in case you can assert that the value of `isQualifying` wasn't taken
let qualifying: Option<u32> = row.take("isQualifying").expect("it is absurd if column value isn't there"); Consider also:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using the take api and in order to handle nulls I need to do something like this:
let qualifying: Option<u32> = if let Some(some_val) = row.take("isQualifying") { some_val } else { None };
What I don't understand, is the take api returns an Optional. At what case can it return None if not in the null case.
If I try
let qualifying: Option<u32> = row.take("isQualifying");
it crashes on null saying it can't convert null to u32. It seems like it should convert null to None?
Thanks for helping me understand
Beta Was this translation helpful? Give feedback.
All reactions