Repository navigation
feat(tui): make a new, empty SQLite database file from the browser - #823
Merged
Merged
Conversation
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
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: #709
Related issue: #822
What changes for users
database file browser (
Ctrl+Oon File),nin 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).Entermakes the file emptywith
fsutil::create_new, which never replaces anything, in the folder the selection standsfor (as the export tree's
nmakes its folder there), then picks it: the field gets itsabsolute path, as a pick does. The browser's footer says
n new file.hold: refused in the prompt, with words, are an empty name,
/or\,.and.., thecharacters 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 newcheck_file_namethat 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.
SQLITE_OPEN_CREATE, as before.SQLite reads a 0-byte file as an empty database, which the driver test below proves.
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 thefile'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.there" error now say connecting never creates the file;
docs/keybindings.mdregenerated.Failing first:
On #814's head (main
f90de4fe), the new flow tests fail:n_makes_a_file_only_in_the_tree_of_the_database_filepasses there too: it guards thatnstaystyped in the filter and free in the other file trees. The driver test
an_empty_file_is_an_empty_database_read_write_and_read_onlypasses on #814's head as well: itpins the SQLite behaviour this feature relies on (a file made by
create_newwith no bytesopens read-write and read-only, Test answers, a table can be made), with no driver change.
Tests
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
0555folder),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_files.rs):a_long_path_in_a_question_wraps_at_a_folder_separator(close and replace questions).crates/drivers/sqlite/tests/integration_sqlite.rs):an_empty_file_is_an_empty_database_read_write_and_read_only.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.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 closequestion with a long path; Unix).
sqlite_file_browser_en_*changes only in its footer (n new file).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.mdregenerated withDATARIG_BLESS=1(the tree's and the name input's descriptions).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.