You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems like this has something to do with handling connection strings as URLs. I set a breakpoint in core::str::trim_start_matches and checked on the call here - when passing in a connection string "sqlite://./test directory/data.db" the value of self is "sqlite://./test\\%20directory/data.db". This is good for postgres/mysql connections as they really are URLs, but not so much for SQLite. For reference, the SQLite docs say percent-encoding is optional, so the double-backslash is probably what trips it up.
Minimal reproduction:
# Cargo.toml
[package]
name = "sqlx_test"version = "0.1.0"edition = "2018"
[dependencies]
sqlx = { version = "0.3", default-features = false, features = [ "runtime-tokio", "sqlite" ] }
tokio = { version = "0.2.17", features = ["full"] }
/* src/main.rs */use sqlx::{prelude::*,SqliteConnection};#[tokio::main]asyncfnmain(){let db_file = std::env::args().nth(1).unwrap();letmut conn = SqliteConnection::connect("sqlite://".to_string() + &db_file).await.unwrap();
conn.execute("CREATE TABLE IF NOT EXISTS things (id INT PRIMARY KEY NOT NULL)").await.unwrap();}
$ mkdir 'test'
$ cargo run -- test/data.db
...
$ mkdir 'test directory'
$ cargo run -- 'test directory/data.db'
...
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Database(SqliteError { code: "21", message: "bad parameter or other API misuse" })', src/main.rs:5:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
From what I saw in some other issue comments here, I understand that the URL handling may be a temporary solution (?) for cleaning up the connection strings - I would be willing to help on the path forward, whether that means a small fix for this or for larger changes. Let me know if that sounds appealing.
The text was updated successfully, but these errors were encountered:
Seems like this has something to do with handling connection strings as URLs. I set a breakpoint in
core::str::trim_start_matches
and checked on the call here - when passing in a connection string"sqlite://./test directory/data.db"
the value ofself
is"sqlite://./test\\%20directory/data.db"
. This is good for postgres/mysql connections as they really are URLs, but not so much for SQLite. For reference, the SQLite docs say percent-encoding is optional, so the double-backslash is probably what trips it up.Minimal reproduction:
From what I saw in some other issue comments here, I understand that the URL handling may be a temporary solution (?) for cleaning up the connection strings - I would be willing to help on the path forward, whether that means a small fix for this or for larger changes. Let me know if that sounds appealing.
The text was updated successfully, but these errors were encountered: