Open CodingDoug opened 1 year ago
On the point of the last question about the use of Option in rusqlite: https://stackoverflow.com/a/70819044
...in general, the tool for “might be null” in Rust is Option, and taking a look at rusqlite::ToSql confirms that there is a
impl<T: ToSql> ToSql for Option<T>
which does what you want. (It's undocumented, unfortunately, but following the “[src]” link shows its implementation.) To use it:
if person.name == "null" { None } else { Some(person.name) }
Another thing to note here - execute
in rusqlite fails with the following message if the query returns any rows at all:
Execute returned results - did you mean to call query?
Porting from the example provided by rusqlite in its documentation:
When ported verbatim to libsql changing only the crate:
The following error results:
As someone inexperienced in Rust, the only way I can easily see to make this particular example compile is not straightforward to me:
Also note also that libsql does not seem to accept
Option
parameters likeme.name
. Apparently rusqlite takesNone
to mean SQLNULL
that libsql should also take?