Skip to content

feat(tui): make a new, empty SQLite database file from the browser - #823

Merged
DokaDev merged 2 commits into
mainfrom
files-048/5-new-db-file
Dec 6, 2026
Merged

DokaDev merged 2 commits into
mainfrom
files-048/5-new-db-file

Conversation

@DokaDev

@DokaDev DokaDev commented Dec 6, 2026 •

Copy link
Copy Markdown
Owner

Related issue: #709
Related issue: #822

What changes for users

  • A new, empty SQLite database file from the browser (Pick a SQLite database file from a file browser #709, plan Q2 b). In the profile form's
    database file browser (Ctrl+O on File), n in the tree asks for a name in a small prompt:
    "New database file", the folder it goes into ("In ~/data/"), a Name field and "An empty file;
    an existing file is never replaced." (Enter create · Esc back). Enter makes the file empty
    with fsutil::create_new, which never replaces anything, in the folder the selection stands
    for (as the export tree's n makes its folder there), then picks it: the field gets its
    absolute path, as a pick does. The browser's footer says n new file.
  • The name is taken as typed (no extension added) and must be one file's name every OS can
    hold: refused in the prompt, with words, are an empty name, / or \, . and .., the
    characters Windows refuses, a space at either end or a dot at the end, the names Windows
    reserves and names over 255 bytes (the saved-query checks, scripts::name, through a new
    check_file_name that allows a hidden name). A file or folder of that name is refused
    ("a file or folder with this name exists; an existing file is never replaced") and stays
    untouched; a folder that cannot be written says so. Any other failure closes the prompt and
    says why; a folder that does not answer is said in the browser, as for the export tree.
  • Connecting still never makes a file: the driver opens without SQLITE_OPEN_CREATE, as before.
    SQLite reads a 0-byte file as an empty database, which the driver test below proves.
  • Long paths in questions (Wrap a long file path in a question at a folder separator, not inside a name #822). The close and replace questions of a file from disk, the
    export questions and the browsers' folder errors wrap a long path after a folder separator
    (/, and \ on Windows) where one is near the line's end, never inside a folder's or the
    file's name, and keep the file name on one line where it fits. Text written against the path
    (the . after it, a Korean particle) stays with it. Helper: text::wrap_path, with unit tests.
  • Docs: the SQLite guide ("Making a new file"), the configuration reference and the "no file
    there" error now say connecting never creates the file; docs/keybindings.md regenerated.

Failing first:

On #814's head (main f90de4fe), the new flow tests fail:

$ cargo test -p datarig-tui --test it -- flows_form_files::n_ flows_form_files::a_name_that_exists flows_form_files::a_folder_that_cannot_be_written_refuses_the_new_file flows_files::a_long_path
test flows_files::a_long_path_in_a_question_wraps_at_a_folder_separator ... FAILED
test flows_form_files::a_folder_that_cannot_be_written_refuses_the_new_file_in_words ... FAILED
test flows_form_files::a_name_that_exists_or_cannot_be_a_file_name_is_refused_in_the_prompt ... FAILED
test flows_form_files::n_in_the_database_file_browser_makes_an_empty_file_and_picks_it ... FAILED
test flows_form_files::n_makes_a_file_only_in_the_tree_of_the_database_file ... ok
test flows_form_files::n_makes_the_file_in_the_folder_selected ... FAILED

---- n_in_the_database_file_browser_makes_an_empty_file_and_picks_it
assertion `left == right` failed: n asks for a name
  left: Some(ScriptTree)
 right: Some(NameInput)
---- a_name_that_exists_or_cannot_be_a_file_name_is_refused_in_the_prompt
assertion `left == right` failed: "shop.db": still asking
  left: Some(ScriptTree)
 right: Some(NameInput)
---- a_folder_that_cannot_be_written_refuses_the_new_file_in_words
assertion `left == right` failed: still asking
  left: Some(ProfileForm)
 right: Some(NameInput)
---- n_makes_the_file_in_the_folder_selected
panicked at flows_form_files.rs:788: no "In ~/data/old/" on the screen (no prompt; the screen followed)
---- a_long_path_in_a_question_wraps_at_a_folder_separator
2026-december-closing whole at 80x24:
| Its changes are not saved to                             |
| ~/work/quarterly-reports/finance-and-operations/2026-dec |
| ember-closing/reviewed/monthly-revenue-totals.sql.       |

test result: FAILED. 1 passed; 5 failed; 0 ignored; 0 measured; 2413 filtered out

n_makes_a_file_only_in_the_tree_of_the_database_file passes there too: it guards that n stays
typed in the filter and free in the other file trees. The driver test
an_empty_file_is_an_empty_database_read_write_and_read_only passes on #814's head as well: it
pins the SQLite behaviour this feature relies on (a file made by create_new with no bytes
opens read-write and read-only, Test answers, a table can be made), with no driver change.

Tests

  • Flows (crates/tui/tests/it/flows_form_files.rs): n_in_the_database_file_browser_makes_an_empty_file_and_picks_it,
    n_makes_the_file_in_the_folder_selected, a_name_that_exists_or_cannot_be_a_file_name_is_refused_in_the_prompt
    (the file's bytes and the folder's names unchanged), a_folder_that_cannot_be_written_refuses_the_new_file_in_words
    (Unix: a real 0555 folder), n_makes_a_file_only_in_the_tree_of_the_database_file,
    a_new_file_in_a_folder_that_does_not_answer_or_fails_is_said (a fake folder that hangs, then one that fails).
  • Flows (flows_files.rs): a_long_path_in_a_question_wraps_at_a_folder_separator (close and replace questions).
  • Driver (crates/drivers/sqlite/tests/integration_sqlite.rs): an_empty_file_is_an_empty_database_read_write_and_read_only.
  • Unit: text::tests::a_long_path_wraps_after_a_folder_separator_never_inside_a_name,
    a_path_that_fits_a_line_moves_to_the_next_one_whole, a_path_keeps_its_spaces_and_the_text_written_against_it
    (Windows separators tested on every OS); app::new_db_file::tests::a_name_is_one_file_name_every_os_can_hold;
    core scripts::tests::a_file_name_may_be_hidden_and_is_one_name. These use new functions, so they do not build on feat(tui): open and save .sql files from disk in their own tabs #814's head.
  • Snapshots, English pinned at 80x24 and 120x40, Korean checked by the harness: new_database_file_en_* (the prompt, M8),
    new_database_file_exists_en_* (a name that exists, refused in the prompt), file_close_long_path_en_* (the close
    question with a long path; Unix). sqlite_file_browser_en_* changes only in its footer (n new file).
  • Local gate: cargo fmt --all --check, cargo clippy --workspace --all-targets --locked -- -D warnings,
    cargo test --workspace --locked --no-fail-fast (5,875 passed, 0 failed), scripts/text-style.py.
    docs/keybindings.md regenerated with DATARIG_BLESS=1 (the tree's and the name input's descriptions).
  • The part Wrap a long file path in a question at a folder separator, not inside a name #822 commit was checked on its own too (its tests and clippy -p datarig-tui --all-targets).

Size

Measured by CI's performance job at 7b411173: the Linux binary is 34,802,544 bytes, 33.190 MiB against the 34 MiB budget (#814's head measured 33.162 MiB, so this part adds about 0.03 MiB). The budget is unchanged.

A question about a file from disk ("Close ...?", "Replace the file?"), an export question and a
file browser's folder error wrapped a long path where the line ended, often inside a folder's
or the file's name. text::wrap_path breaks a path only after a folder separator (`/`, and `\`
on Windows), moves a path that fits a line to the next one whole, keeps the file name on one
line where it fits, and keeps text written against the path (the `.` after it, a Korean
particle) with its end.

Part of #822
`n` in the tree of the SQLite database file's browser asks for a name: "New database file",
the folder it goes into, and "An empty file; an existing file is never replaced.". Enter makes
the file empty with fsutil::create_new, which never replaces anything, on the folder reads'
worker, then picks it as Enter on a file does: the field gets its absolute path.

The name is taken as typed (no extension added) and must be one file name every OS can hold:
scripts::name::check_file_name, the saved-query checks with a hidden name allowed. A name that
exists and a folder that cannot be written are refused in the prompt; another failure closes
it and says why. Connecting still never makes a file, and the "no file there" error says so.

A driver test proves that SQLite reads the empty file as an empty database, read-write and
read-only, that Test answers, and that a table can be made in it.

Part of #709
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-06T09:57:36.649915Z 7b41117 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@DokaDev DokaDev changed the title files 048/5 new db file feat(tui): make a new, empty SQLite database file from the browser Dec 6, 2026
@DokaDev
DokaDev merged commit 7c63f79 into main Dec 6, 2026
24 of 25 checks passed
@DokaDev
DokaDev deleted the files-048/5-new-db-file branch December 6, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant