From 09b72d31d41d9535e771c0a19bd937bec5fb12a2 Mon Sep 17 00:00:00 2001 From: thekevinbot <248217931+thekevinbot@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:57:54 -0500 Subject: [PATCH 1/5] Test that a ../ config glob climbs out of a verbatim config directory --- packages/rust/src/path_table.rs | 12 +++++++ packages/rust/tests/cli_config_anchor.rs | 44 +++++++++++++++++++++++ packages/rust/tests/cli_missing_anchor.rs | 31 ++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 packages/rust/tests/cli_config_anchor.rs diff --git a/packages/rust/src/path_table.rs b/packages/rust/src/path_table.rs index ec278537f..35a0771e7 100644 --- a/packages/rust/src/path_table.rs +++ b/packages/rust/src/path_table.rs @@ -1123,6 +1123,18 @@ mod tests { ); } + #[test] + fn a_parent_relative_config_glob_climbs_out_of_a_verbatim_config_directory() { + assert_eq!( + config_anchor_as::( + "../data/*.json", + Path::new(r"\\?\C:\work\cfg"), + None + ), + Some((PathBuf::from(r"\\?\C:\work\data"), "*.json".to_string())) + ); + } + #[test] fn a_drive_letter_path_folds_a_parent_component_as_windows_does() { let t = table(r"C:\var\x\..\log\*.log", ¬hing_is_a_dir); diff --git a/packages/rust/tests/cli_config_anchor.rs b/packages/rust/tests/cli_config_anchor.rs new file mode 100644 index 000000000..b51655152 --- /dev/null +++ b/packages/rust/tests/cli_config_anchor.rs @@ -0,0 +1,44 @@ +//! A config glob passed with `-c` anchors at the config's directory, `../` +//! included. +//! +//! Gated behind `--features cli` like the sibling CLI e2e tests. +#![cfg(feature = "cli")] + +use std::fs; + +use assert_cmd::prelude::*; +use tempfile::TempDir; + +const HOOK: &str = r#"on-file = '''sh -c 'for p; do p=$(printf %s "$p" | tr "\\\\" /); printf "{\"basename\":\"%s\"}\n" "${p##*/}"; done' sh'''"#; + +#[test] +fn a_parent_relative_config_glob_matches_files_above_the_config() { + let dir = TempDir::new().unwrap(); + let cfg_dir = dir.path().join("cfg"); + fs::create_dir(&cfg_dir).unwrap(); + fs::create_dir(dir.path().join("data")).unwrap(); + fs::write(dir.path().join("data/a.json"), "{}").unwrap(); + let cfg = cfg_dir.join(".dirsql.toml"); + fs::write( + &cfg, + format!( + "[[table]]\nname = \"docs\"\nddl = \"CREATE TABLE docs (basename TEXT)\"\nglob = '../data/*.json'\n{HOOK}\n" + ), + ) + .unwrap(); + + let out = std::process::Command::cargo_bin("dirsql") + .expect("`dirsql` binary must be built by `cargo test` with --features cli") + .arg("query") + .arg("SELECT basename FROM docs") + .arg("-c") + .arg(&cfg) + .current_dir(&cfg_dir) + .output() + .unwrap(); + + let stdout = String::from_utf8_lossy(&out.stdout); + let stderr = String::from_utf8_lossy(&out.stderr); + assert!(out.status.success(), "stderr: {stderr}"); + assert!(stdout.contains("a.json"), "stdout: {stdout}\nstderr: {stderr}"); +} diff --git a/packages/rust/tests/cli_missing_anchor.rs b/packages/rust/tests/cli_missing_anchor.rs index 0c0d9e4ca..deed09729 100644 --- a/packages/rust/tests/cli_missing_anchor.rs +++ b/packages/rust/tests/cli_missing_anchor.rs @@ -47,3 +47,34 @@ fn a_config_table_whose_directory_is_missing_fails_the_query() { "{stderr}" ); } + +#[test] +fn a_config_table_above_the_config_whose_directory_is_missing_fails_the_query() { + let dir = TempDir::new().unwrap(); + let cfg_dir = dir.path().join("cfg"); + fs::create_dir(&cfg_dir).unwrap(); + let cfg = cfg_dir.join(".dirsql.toml"); + fs::write( + &cfg, + "[[table]]\nname = \"later\"\nddl = \"CREATE TABLE later (x TEXT)\"\nglob = '../absent/*.json'\non-file = \"true\"\n", + ) + .unwrap(); + + let out = std::process::Command::cargo_bin("dirsql") + .expect("`dirsql` binary must be built by `cargo test` with --features cli") + .arg("query") + .arg("SELECT COUNT(*) AS n FROM later") + .arg("-c") + .arg(&cfg) + .current_dir(&cfg_dir) + .output() + .unwrap(); + + let stderr = String::from_utf8_lossy(&out.stderr); + assert!(!out.status.success(), "exited zero; stderr: {stderr}"); + assert!( + stderr.contains("table 'later': its directory ") + && stderr.contains("absent does not exist"), + "{stderr}" + ); +} From 48d903c7b99300cbc90c02f9771c6273ba76aa4e Mon Sep 17 00:00:00 2001 From: thekevinbot <248217931+thekevinbot@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:03:16 -0500 Subject: [PATCH 2/5] Join a written ../ or ~/ suffix one component at a time --- .../2026-11-18-windows-dotdot-config-glob.md | 1 + .../2026-11-18-windows-dotdot-config-glob.md | 24 +++++++++++++++++++ packages/rust/src/path_table.rs | 14 +++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 packages/rust/changelog.d/2026-11-18-windows-dotdot-config-glob.md create mode 100644 packages/rust/migrations.d/2026-11-18-windows-dotdot-config-glob.md diff --git a/packages/rust/changelog.d/2026-11-18-windows-dotdot-config-glob.md b/packages/rust/changelog.d/2026-11-18-windows-dotdot-config-glob.md new file mode 100644 index 000000000..679e54dbb --- /dev/null +++ b/packages/rust/changelog.d/2026-11-18-windows-dotdot-config-glob.md @@ -0,0 +1 @@ +**Fixed** On Windows, a config `[[table]] glob` starting with `../` now anchors above the config's directory when the config path is a verbatim (`\\?\`) path, as the CLI's `-c` produces; it used to match nothing. diff --git a/packages/rust/migrations.d/2026-11-18-windows-dotdot-config-glob.md b/packages/rust/migrations.d/2026-11-18-windows-dotdot-config-glob.md new file mode 100644 index 000000000..8c89e433a --- /dev/null +++ b/packages/rust/migrations.d/2026-11-18-windows-dotdot-config-glob.md @@ -0,0 +1,24 @@ +### Rust core: `../` config globs anchor correctly under a verbatim config path + +**Summary** + +On Windows, a config glob such as `../data/*.json` loaded from a verbatim (`\\?\`) config path now anchors at the config directory's parent, as it already did on other platforms and for non-verbatim paths. A bug fix; nothing breaks. + +**Required changes** + +_None._ + +**Deprecations removed** + +_None._ + +**Behavior changes without code changes** + +On Windows, a `../` config glob under a verbatim config path that used to match nothing now matches the files it names. + +**Verification** + +```bash +cargo test -p dirsql --features cli --test cli_config_anchor +# test result: ok. +``` diff --git a/packages/rust/src/path_table.rs b/packages/rust/src/path_table.rs index 35a0771e7..2625a259f 100644 --- a/packages/rust/src/path_table.rs +++ b/packages/rust/src/path_table.rs @@ -313,10 +313,10 @@ fn absolute_target( home: Option<&Path>, ) -> Option>> { if let Some(rest) = S::HOME_PREFIXES.iter().find_map(|p| name.strip_prefix(p)) { - return Some(home.map(|h| typed::(h).join(rest))); + return Some(home.map(|h| join_written(typed::(h), rest))); } if name.starts_with("../") { - return Some(Some(typed::(index_root).join(name))); + return Some(Some(join_written(typed::(index_root), name))); } if S::is_rooted(name) { return Some(Some(Utf8PathBuf::from(name))); @@ -324,6 +324,16 @@ fn absolute_target( None } +/// `base` with the written `rest` appended one component at a time. Joined +/// whole onto a verbatim (`\\?\`) base, `rest` would be one component with +/// its `/` kept literal. +fn join_written(mut base: Utf8PathBuf, rest: &str) -> Utf8PathBuf { + for part in rest.split(S::SEPARATORS).filter(|p| !p.is_empty()) { + base.push(part); + } + base +} + /// Fold `.` and `..` out of `path` lexically. Purely textual: a `..` is not /// resolved through a symlink. fn normalize(path: &Utf8Path) -> Utf8PathBuf { From 4d39a95ae69bddf7dae5c8998d02553a304931e5 Mon Sep 17 00:00:00 2001 From: thekevinbot <248217931+thekevinbot@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:07:51 -0500 Subject: [PATCH 3/5] e2e attestation for bot/1770-windows-dotdot-glob-1118 --- .../bot-1770-windows-dotdot-glob-1118.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 packages/python/e2e-attestations/bot-1770-windows-dotdot-glob-1118.json diff --git a/packages/python/e2e-attestations/bot-1770-windows-dotdot-glob-1118.json b/packages/python/e2e-attestations/bot-1770-windows-dotdot-glob-1118.json new file mode 100644 index 000000000..a544e1f03 --- /dev/null +++ b/packages/python/e2e-attestations/bot-1770-windows-dotdot-glob-1118.json @@ -0,0 +1,7 @@ +{ + "command": "uv run python -m pytest tests/e2e/declared_table_name_test.py tests/e2e/query_contract_test.py -x -q", + "ran_at": 1795054070, + "exit_code": 0, + "commit": "48d903c7b99300cbc90c02f9771c6273ba76aa4e", + "branch": "bot/1770-windows-dotdot-glob-1118" +} From 82c4847050a6a92dce8cb742bf9e6d3e934aebc4 Mon Sep 17 00:00:00 2001 From: thekevinbot <248217931+thekevinbot@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:09:03 -0500 Subject: [PATCH 4/5] e2e attestation for bot/1770-windows-dotdot-glob-1118 --- .../bot-1770-windows-dotdot-glob-1118.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 packages/ts/e2e-attestations/bot-1770-windows-dotdot-glob-1118.json diff --git a/packages/ts/e2e-attestations/bot-1770-windows-dotdot-glob-1118.json b/packages/ts/e2e-attestations/bot-1770-windows-dotdot-glob-1118.json new file mode 100644 index 000000000..84b9a828e --- /dev/null +++ b/packages/ts/e2e-attestations/bot-1770-windows-dotdot-glob-1118.json @@ -0,0 +1,7 @@ +{ + "command": "pnpm test:e2e", + "ran_at": 1795054143, + "exit_code": 0, + "commit": "4d39a95ae69bddf7dae5c8998d02553a304931e5", + "branch": "bot/1770-windows-dotdot-glob-1118" +} From 078c8c7273953ffe9918136b9666333a016e35eb Mon Sep 17 00:00:00 2001 From: thekevinbot <248217931+thekevinbot@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:54:09 -0500 Subject: [PATCH 5/5] Format cli_config_anchor test --- packages/rust/tests/cli_config_anchor.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/rust/tests/cli_config_anchor.rs b/packages/rust/tests/cli_config_anchor.rs index b51655152..c17f57d97 100644 --- a/packages/rust/tests/cli_config_anchor.rs +++ b/packages/rust/tests/cli_config_anchor.rs @@ -40,5 +40,8 @@ fn a_parent_relative_config_glob_matches_files_above_the_config() { let stdout = String::from_utf8_lossy(&out.stdout); let stderr = String::from_utf8_lossy(&out.stderr); assert!(out.status.success(), "stderr: {stderr}"); - assert!(stdout.contains("a.json"), "stdout: {stdout}\nstderr: {stderr}"); + assert!( + stdout.contains("a.json"), + "stdout: {stdout}\nstderr: {stderr}" + ); }