Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop urlencoding dependency #3162

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sqlx-sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ uuid = { workspace = true, optional = true }

url = { version = "2.2.2", default-features = false }
percent-encoding = "2.1.0"
serde_urlencoded = "0.7"

flume = { version = "0.11.0", default-features = false, features = ["async"] }

Expand All @@ -43,7 +44,6 @@ tracing = { version = "0.1.37", features = ["log"] }

serde = { version = "1.0.145", features = ["derive"], optional = true }
regex = { version = "1.5.5", optional = true }
urlencoding = "2.1.3"

[dependencies.libsqlite3-sys]
version = "0.27.0"
Expand Down
14 changes: 8 additions & 6 deletions sqlx-sqlite/src/connection/establish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use libsqlite3_sys::{
SQLITE_OPEN_CREATE, SQLITE_OPEN_FULLMUTEX, SQLITE_OPEN_MEMORY, SQLITE_OPEN_NOMUTEX,
SQLITE_OPEN_PRIVATECACHE, SQLITE_OPEN_READONLY, SQLITE_OPEN_READWRITE, SQLITE_OPEN_SHAREDCACHE,
};
use percent_encoding::NON_ALPHANUMERIC;
use sqlx_core::IndexMap;
use std::collections::BTreeMap;
use std::ffi::{c_void, CStr, CString};
use std::io;
use std::os::raw::c_int;
Expand Down Expand Up @@ -92,21 +94,21 @@ impl EstablishParams {
SQLITE_OPEN_PRIVATECACHE
};

let mut query_params: Vec<String> = vec![];
let mut query_params = BTreeMap::new();

if options.immutable {
query_params.push("immutable=true".into())
query_params.insert("immutable", "true");
}

if let Some(vfs) = &options.vfs {
query_params.push(format!("vfs={vfs}"))
if let Some(vfs) = options.vfs.as_deref() {
query_params.insert("vfs", &vfs);
}

if !query_params.is_empty() {
filename = format!(
"file:{}?{}",
urlencoding::encode(&filename),
query_params.join("&")
percent_encoding::percent_encode(filename.as_bytes(), &NON_ALPHANUMERIC),
serde_urlencoded::to_string(&query_params).unwrap()
);
flags |= libsqlite3_sys::SQLITE_OPEN_URI;
}
Expand Down
Loading