Skip to content

Prevent table names from colliding in dump filenames - #17

Open
vibhor-aggr wants to merge 1 commit into
simonw:mainfrom
vibhor-aggr:fix/escaped-dump-filenames
Open

vibhor-aggr wants to merge 1 commit into
simonw:mainfrom
vibhor-aggr:fix/escaped-dump-filenames

Conversation

@vibhor-aggr

Copy link
Copy Markdown

Fixes #1.

With tables named foo/bar and foobar, dump --all succeeds on 0.6 but writes just one pair of files. One table silently overwrites the other. This change gives foo/bar the stem foo%2Fbar, leaves foobar unchanged, and escapes a literal foo%2Fbar as foo%252Fbar. The name doesn't depend on which other tables are being dumped. Spaces and ordinary Unicode are preserved; very long stems use a reserved hash prefix.

The loader still gets the table name from metadata. It now strips only the final metadata suffix, so names such as sales.metadata round-trip too. Existing unambiguous dumps remain readable. An old dump that already lost a table to a collision must be regenerated from the original database; dumping doesn't delete obsolete files.

Verification: 10 behavior tests passed on CPython 3.12 and 3.14, each with sqlite-utils 3.39.1 and 4.2.2. The Black-only test was excluded locally (marked to skip on these interpreters). In an independent CLI replay, seven tables retained their exact schema SQL, keys and values; subset and full dumps agreed byte-for-byte, and the new loader restored a dump written by the old code. Fixture dumps using all 20 table names in the README's linked backup had identical filenames and contents before and after. No backup data was downloaded.

Prepared and tested with Codex assistance.

This branch has not been deployed

No deployments
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.

Handle tables with surprising names

1 participant