Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [unreleased]

### 🚀 Features

- Add SQLite-backed interactive history with safe connection metadata (#32); store it in the platform state/data directory

### 📚 Documentation

- Remove use_copy option from CedarDB example
Expand Down
153 changes: 150 additions & 3 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ arrow-schema = "59.3.0"
clap = { version = "4.6.7", features = ["derive"] }
comfy-table = "8.0.1"
nu-ansi-term = "0.50.3"
chrono = "0.4.41"
dirs = "6.0.0"
reedline = { version = "0.52.0", features = ["sqlite"] }
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
parquet = { version = "59.3.0", default-features = false, features = ["arrow", "snap"] }
reedline = "0.52.0"
syntect = "5.3.0"
tempfile = "3.27.0"
terminal-colorsaurus = "1.0.3"
Expand Down
27 changes: 23 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ pub fn parse_args() -> AppConfig {
}
}

pub(crate) fn uri_driver_scheme(uri: &str) -> Option<&str> {
let (scheme, _) = uri.split_once(':')?;
let mut chars = scheme.chars();
if !chars.next().is_some_and(|c| c.is_ascii_alphabetic())
|| !chars.all(|c| c.is_ascii_alphanumeric() || matches!(c, '+' | '-' | '.'))
{
return None;
}
Some(scheme)
}

/// Parse all `key=value` values supplied for the argument `id`, exiting with an
/// error message if any value is malformed.
fn collect_options(matches: &clap::ArgMatches, id: &str) -> Vec<(String, String)> {
Expand All @@ -200,10 +211,7 @@ fn parse_output_path(s: &str) -> Result<PathBuf, String> {
}

fn uri_has_driver_scheme(uri: &str) -> bool {
let Some(idx) = uri.find(':') else {
return false;
};
idx != 0
uri_driver_scheme(uri).is_some()
}

fn parse_option(option: &str) -> Result<(String, String), String> {
Expand Down Expand Up @@ -300,6 +308,10 @@ mod tests {
assert!(!uri_has_driver_scheme("plain_path"));
// Empty scheme (leading colon).
assert!(!uri_has_driver_scheme(":memory:"));
// A scheme must start with an ASCII letter and contain only RFC 3986
// scheme characters after it.
assert!(!uri_has_driver_scheme("not a scheme://x"));
assert!(!uri_has_driver_scheme("duck/db://x"));
}

#[test]
Expand All @@ -309,6 +321,13 @@ mod tests {
assert!(uri_has_driver_scheme("PROFILE://my_database"));
}

#[test]
fn test_uri_driver_scheme_preserves_original_case() {
assert_eq!(uri_driver_scheme("DuckDB://x"), Some("DuckDB"));
assert_eq!(uri_driver_scheme("sqlite::memory:"), Some("sqlite"));
assert_eq!(uri_driver_scheme(":memory:"), None);
}

#[test]
fn test_connection_source_profile_with_path() {
let source = ConnectionSource::Profile {
Expand Down
Loading
Loading