Skip to content

Commit 0085e60

Browse files
authored
Merge pull request #219 from dbcli/krace/issue-149-add-index-command-to-schema
Return indexes when .schema is run
2 parents 62f5adf + e483156 commit 0085e60

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
* Fix a bug where the `\llm` command on alternate invocations weren't detected correctly. (#211)
1313
* Do not escape upper table or column name. [(#185)](https://github.com/dbcli/litecli/issues/185)
14+
* Return indices when `.schema` command is run. Also update the output to contain the `sql` for the `indexes` command. [(#149)](https://github.com/dbcli/litecli/issues/149)
1415

1516
### Internal
1617

litecli/packages/special/dbcommands.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def show_schema(cur, arg=None, **_):
102102
args = (arg,)
103103
query = """
104104
SELECT sql FROM sqlite_master
105-
WHERE name==? AND sql IS NOT NULL
105+
WHERE tbl_name==? AND sql IS NOT NULL
106106
ORDER BY tbl_name, type DESC, name
107107
"""
108108
else:
@@ -124,7 +124,6 @@ def show_schema(cur, arg=None, **_):
124124

125125
return [(None, tables, headers, status)]
126126

127-
128127
@special_command(
129128
".databases",
130129
".databases",
@@ -143,7 +142,6 @@ def list_databases(cur, **_):
143142
else:
144143
return [(None, None, None, "")]
145144

146-
147145
@special_command(
148146
".indexes",
149147
".indexes [tablename]",
@@ -156,14 +154,14 @@ def list_indexes(cur, arg=None, arg_type=PARSED_QUERY, verbose=False):
156154
if arg:
157155
args = ("{0}%".format(arg),)
158156
query = """
159-
SELECT name FROM sqlite_master
157+
SELECT name, sql FROM sqlite_master
160158
WHERE type = 'index' AND tbl_name LIKE ? AND name NOT LIKE 'sqlite_%'
161159
ORDER BY 1
162160
"""
163161
else:
164162
args = tuple()
165163
query = """
166-
SELECT name FROM sqlite_master
164+
SELECT name, sql FROM sqlite_master
167165
WHERE type = 'index' AND name NOT LIKE 'sqlite_%'
168166
ORDER BY 1
169167
"""

litecli/packages/special/llm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
except ImportError:
2121
llm = None
2222
cli = None
23+
LLM_CLI_COMMANDS = []
24+
MODELS = {}
2325

2426
from . import export
2527
from .main import parse_special_command

litecli/sqlexecute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SQLExecute(object):
3838
"""
3939

4040
indexes_query = """
41-
SELECT name
41+
SELECT name, sql
4242
FROM sqlite_master
4343
WHERE type = 'index' AND name NOT LIKE 'sqlite_%'
4444
ORDER BY 1

0 commit comments

Comments
 (0)