Fallback to default values for NULL columns in Rust SQLite

Posted by Alexander Todorov on Fri 27 October 2017

I have been working on code which changed its DB schema to add a NULL column without a default value! The standard row.get() from Rusqlite throws errors because NULL is not a valid integer value.

The solution is to use row.get_checked() like so:

let build_id = row.get_checked(3).unwrap_or(0);

Interestingly enough I wasn't able to find clear information about this on the Internet so here it is.

Thanks for reading and happy hacking!



Comments !