Overhaul schema
command, remove database name
#7344
Merged
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.
This PR changes the
schema
command for viewing the schema of a SQLite database file. It removes 1 level of nesting (intended to handle multiple databases in the same connection) that I believe is unnecessary.Before
After
Rationale
A SQLite database connection can technically be associated with multiple non-temporary databases using the ATTACH DATABASE command. But it's not possible to do that in the context of Nushell, and so I believe that there is no benefit to displaying the schema as if there could be multiple databases.
I initially raised this concern back in April, but we decided to keep the database nesting because at the time we were still looking into more generalized database functionality (i.e. not just SQLite). I believe that rationale no longer applies.
Also, the existing code would not have worked correctly even if a connection had multiple databases; for every database, it was looking up tables without filtering them by database:
nushell/crates/nu-command/src/database/values/sqlite.rs
Lines 104 to 118 in 6295b20
Future Work
I'd like to add information on views+triggers to the
schema
output. I'm also working on making it possible toctrl+c
reading from a database (which is turning into a massive yak shave).