Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul
schema
command, remove database name (#7344)
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 ![image](https://user-images.githubusercontent.com/26268125/205467643-05df0f64-bc8f-4135-9ff1-f978cc7a12bd.png) ### After ![image](https://user-images.githubusercontent.com/26268125/205467655-c4783184-9bde-46e2-9316-0f06acd1abe1.png) ## Rationale A SQLite database connection can technically be associated with multiple non-temporary databases using [the ATTACH DATABASE command](https://www.sqlite.org/lang_attach.html). 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: https://github.com/nushell/nushell/blob/6295b205450bde26ed62f08cc825005c2267d90d/crates/nu-command/src/database/values/sqlite.rs#L104-L118 ## Future Work I'd like to add information on views+triggers to the `schema` output. I'm also working on making it possible to `ctrl+c` reading from a database (which is turning into a massive yak shave).
- Loading branch information