diff options
author | Martijn Pieters <mj@zopatista.com> | 2023-11-10 13:07:29 +0000 |
---|---|---|
committer | Martijn Pieters <mj@zopatista.com> | 2023-11-10 13:18:09 +0000 |
commit | 76a6017e8597dfe31a935e2dd79a275c80b5335a (patch) | |
tree | 905002999586dd7c30064d3835b1e2425f1b7f4f | |
parent | f4246296016943b3533f00679efec7a4d4bfa075 (diff) |
Skip internal indexes in .schema output
See the [schema table `sql` column documentation][schema]:
> The `sqlite_schema.sql` is NULL for the internal indexes that are automatically
> created by UNIQUE or PRIMARY KEY constraints.
[schema]: https://www.sqlite.org/schematab.html#interpretation_of_the_schema_table
Fixes #170
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | litecli/packages/special/dbcommands.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d0ba2..4b62259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ of for every line of output ([#148](https://github.com/dbcli/litecli/issues/148)). * Use the sqlite3 API to cancel a running query on interrupt ([#164](https://github.com/dbcli/litecli/issues/164)). +* Skip internal indexes in the .schema output + ([#170](https://github.com/dbcli/litecli/issues/170)). ## 1.9.0 - 2022-06-06 diff --git a/litecli/packages/special/dbcommands.py b/litecli/packages/special/dbcommands.py index 3bba548..dec3507 100644 --- a/litecli/packages/special/dbcommands.py +++ b/litecli/packages/special/dbcommands.py @@ -69,13 +69,14 @@ def show_schema(cur, arg=None, **_): args = (arg,) query = """ SELECT sql FROM sqlite_master - WHERE name==? + WHERE name==? AND sql IS NOT NULL ORDER BY tbl_name, type DESC, name """ else: args = tuple() query = """ SELECT sql FROM sqlite_master + WHERE sql IS NOT NULL ORDER BY tbl_name, type DESC, name """ |