Skip to content

Commit e0a72cf

Browse files
Drop urlencoding dependency (#3162)
1 parent 352b02d commit e0a72cf

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

Cargo.lock

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqlx-sqlite/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ uuid = { workspace = true, optional = true }
3333

3434
url = { version = "2.2.2", default-features = false }
3535
percent-encoding = "2.1.0"
36+
serde_urlencoded = "0.7"
3637

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

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

4445
serde = { version = "1.0.145", features = ["derive"], optional = true }
4546
regex = { version = "1.5.5", optional = true }
46-
urlencoding = "2.1.3"
4747

4848
[dependencies.libsqlite3-sys]
4949
version = "0.28.0"

sqlx-sqlite/src/connection/establish.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ use libsqlite3_sys::{
99
SQLITE_OPEN_CREATE, SQLITE_OPEN_FULLMUTEX, SQLITE_OPEN_MEMORY, SQLITE_OPEN_NOMUTEX,
1010
SQLITE_OPEN_PRIVATECACHE, SQLITE_OPEN_READONLY, SQLITE_OPEN_READWRITE, SQLITE_OPEN_SHAREDCACHE,
1111
};
12+
use percent_encoding::NON_ALPHANUMERIC;
1213
use sqlx_core::IndexMap;
14+
use std::collections::BTreeMap;
1315
use std::ffi::{c_void, CStr, CString};
1416
use std::io;
1517
use std::os::raw::c_int;
@@ -92,21 +94,21 @@ impl EstablishParams {
9294
SQLITE_OPEN_PRIVATECACHE
9395
};
9496

95-
let mut query_params: Vec<String> = vec![];
97+
let mut query_params = BTreeMap::new();
9698

9799
if options.immutable {
98-
query_params.push("immutable=true".into())
100+
query_params.insert("immutable", "true");
99101
}
100102

101-
if let Some(vfs) = &options.vfs {
102-
query_params.push(format!("vfs={vfs}"))
103+
if let Some(vfs) = options.vfs.as_deref() {
104+
query_params.insert("vfs", &vfs);
103105
}
104106

105107
if !query_params.is_empty() {
106108
filename = format!(
107109
"file:{}?{}",
108-
urlencoding::encode(&filename),
109-
query_params.join("&")
110+
percent_encoding::percent_encode(filename.as_bytes(), &NON_ALPHANUMERIC),
111+
serde_urlencoded::to_string(&query_params).unwrap()
110112
);
111113
flags |= libsqlite3_sys::SQLITE_OPEN_URI;
112114
}

0 commit comments

Comments
 (0)