Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/sqlite3/_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _complete(con, text, state):
f"""\
SELECT pti.name || ' ' FROM "{schema}".sqlite_master AS sm
JOIN pragma_table_xinfo(sm.name,'{schema}') AS pti
WHERE sm.type='table' AND
WHERE sm.type IN ('table', 'view') AND
pti.name LIKE REPLACE(:text, '_', '^_') || '%' ESCAPE '^'"""
for schema in schemata
)
Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_sqlite3/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ def test_complete_columns(self):
input_ = textwrap.dedent("""\
CREATE TABLE _table (_col_table);
CREATE TEMP TABLE _temp_table (_col_temp);
CREATE VIEW _view AS SELECT _col_table AS _col_table_alias
FROM _table;
ATTACH ':memory:' AS attached;
CREATE TABLE attached._attached_table (_col_attached);

Expand All @@ -340,9 +342,9 @@ def test_complete_columns(self):
candidates = [l.strip() for l in lines[start+1:end]]

self.assertEqual(
candidates, ["_col_attached", "_col_table", "_col_temp"]
candidates,
["_col_attached", "_col_table", "_col_table_alias", "_col_temp"],
)

@unittest.skipIf(sqlite3.sqlite_version_info < (3, 30, 0),
"PRAGMA function_list is not available until "
"SQLite 3.30.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix :mod:`sqlite3` CLI completer to include view columns in
column-name completion.

Loading