fix: validate --csv-table-name and fix hex-encoded error message#1025
Open
standard-librarian wants to merge 1 commit into
Open
fix: validate --csv-table-name and fix hex-encoded error message#1025standard-librarian wants to merge 1 commit into
standard-librarian wants to merge 1 commit into
Conversation
Adds upfront validation that --csv-table-name is a valid unquoted SQL identifier (starts with a letter or underscore, contains only letters, digits, and underscores). This prevents silent data loss on newer sqlite3 (≥3.37) and cryptic hex error output on older versions. Also fixes the stderr format verb in importCSVIntoSQLite from %x (hex) to %s so sqlite3 error messages are human-readable. Closes tursodatabase#810
4d39f2e to
57fc42e
Compare
Author
|
Hey @penberg, wdyt about this one? Adds upfront validation for --csv-table-name to prevent silent data loss with hyphenated names on newer sqlite3 (≥3.37), and fixes the %x → %s format verb so error messages are readable on older versions too. |
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.
Summary
--csv-table-nameis a valid unquoted SQL identifier (must start with a letter or underscore, contain only letters, digits, and underscores). This prevents silent data loss on newer sqlite3 (≥3.37) where a hyphenated name is accepted but inaccessible without quoting in every query.importCSVIntoSQLitefrom%x(hex) to%sso sqlite3 error messages are human-readable on older sqlite3 versions (≤3.36) that reject the name outright.Test plan
go test ./internal/cmd/... -run TestValidateCSVTableName— 9 table-driven cases covering valid names, hyphen, digit prefix, empty string, spaces, and dotsturso db create --from-csv file.csv --csv-table-name some-table→ clear error:invalid --csv-table-name "some-table": must start with a letter or underscore...turso db create --from-csv file.csv --csv-table-name some_table→ succeeds as beforeCloses #810