tursodatabase / tursodatabase/libsql
execute params argument isn't compatible with rusqlite
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
Porting from the example provided by rusqlite in its documentation:
use rusqlite::{Connection, Result};
#[derive(Debug)]
struct Person {
id: i32,
name: String,
data: Option<Vec<u8>>,
}
let me = Person {
id: 0,
name: "Steven".to_string(),
data: None,
};
conn.execute(
"INSERT INTO person (name, data) VALUES (?1, ?2)",
(&me.name, &me.data),
)?;
When ported verbatim to libsql changing only the crate:
use libsql::{Database, Connection, Result};
The following error results:
error[E0277]: the trait bound `libsql::Params: From<(&String, &Option<std::vec::Vec<u8>>)>` is not satisfied
--> src/libsql/mod.rs:29:9
|
27 | conn.execute(
| ------- required by a bound introduced by this call
28 | "INSERT INTO person (name, data) VALUES (?1, ?2)",
29 | (&me.name, &me.data),
| ^^^^^^^^^^^^^^^^^^^^ the trait `From<(&String, &Option<std::vec::Vec<u8>>)>` is not implemented for `libsql::Params`
|
= help: the following other types implement trait `From<T>`:
<libsql::Params as From<()>>
<libsql::Params as From<std::vec::Vec<(String, libsql::Value)>>>
<libsql::Params as From<std::vec::Vec<libsql::Value>>>
= note: required for `(&String, &Option<std::vec::Vec<u8>>)` to implement `Into<libsql::Params>`
note: required by a bound in `libsql::Connection::execute`
--> /Users/doug/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsql-0.1.6/src/connection.rs:74:12
|
74 | P: Into<Params>,
| ^^^^^^^^^^^^ required by this bound in `Connection::execute`
As someone inexperienced in Rust, the only way I can easily see to make this particular example compile is not straightforward to me:
params![&*me.name]
Also note also that libsql does not seem to accept Option parameters like me.name. Apparently rusqlite takes None to mean SQL NULL that libsql should also take?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the rusqlite documentation example using libsql and inspect the Params conversion required by Connection::execute. Start with the execute signature in connection.rs and the listed Params implementations, then compare tuple references and Option values. Done means the documented parameter style works or the supported limitation is clearly documented and tested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sqlite
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100