Fully qualify the sqlite path for into sqlite (#16349)

- related #16258

# Description


In #16258 we had some trouble getting tests to work properly. After some
investigation with @WindSoilder we figured out that `Table::new` inside
`into_sqlite.rs` did not respect the `$env.PWD`. The underlying
`open_sqlite_db` and in that `Connection::open` respects the current
working directory. That one is updated via `cd` but not necessarily in
tests (and we should not try that). In this PR I join the `$env.PWD`
with the path passed to `into sqlite`.

This PR also adds a test for the auto conversion from #16258.

# User-Facing Changes

Should be none, some edge cases might be fixed now.
This commit is contained in:
Piepmatz
2025-08-05 22:02:33 +02:00
committed by GitHub
parent fcdc7f3d83
commit 61a89c1834
2 changed files with 34 additions and 8 deletions

View File

@ -495,3 +495,16 @@ fn insert_test_rows(dirs: &Dirs, nu_table: &str, sql_query: Option<&str>, expect
assert_eq!(expected, actual_rows);
}
#[test]
fn test_auto_conversion() {
Playground::setup("sqlite json auto conversion", |_, playground| {
let raw = "{a_record:{foo:bar,baz:quux},a_list:[1,2,3],a_table:[[a,b];[0,1],[2,3]]}";
nu!(cwd: playground.cwd(), "{} | into sqlite filename.db -t my_table", raw);
let outcome = nu!(
cwd: playground.cwd(),
"open filename.db | get my_table.0 | to nuon --raw"
);
assert_eq!(outcome.out, raw);
});
}