https://github.com/python/cpython/commit/01a683a3d4dcc8fa2b28873dbe6f57183899ad31
commit: 01a683a3d4dcc8fa2b28873dbe6f57183899ad31
branch: main
author: Tony <[email protected]>
committer: encukou <[email protected]>
date: 2026-10-20T01:50:25+02:00
summary:
gh-158277: sqlite3 CLI completer: include views in column completion (GH-158278)
files:
A Misc/NEWS.d/next/Library/2026-09-27-14-00-00.gh-issue-158277.aBcDeF.rst
M Lib/sqlite3/_completer.py
M Lib/test/test_sqlite3/test_cli.py
diff --git a/Lib/sqlite3/_completer.py b/Lib/sqlite3/_completer.py
index ba580f968bf92dc..12cafc26602f8bb 100644
--- a/Lib/sqlite3/_completer.py
+++ b/Lib/sqlite3/_completer.py
@@ -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
)
diff --git a/Lib/test/test_sqlite3/test_cli.py
b/Lib/test/test_sqlite3/test_cli.py
index 0d235d90f1101b4..e049d16642ce0ca 100644
--- a/Lib/test/test_sqlite3/test_cli.py
+++ b/Lib/test/test_sqlite3/test_cli.py
@@ -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);
@@ -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")
diff --git
a/Misc/NEWS.d/next/Library/2026-09-27-14-00-00.gh-issue-158277.aBcDeF.rst
b/Misc/NEWS.d/next/Library/2026-09-27-14-00-00.gh-issue-158277.aBcDeF.rst
new file mode 100644
index 000000000000000..7f0434aeea67081
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-09-27-14-00-00.gh-issue-158277.aBcDeF.rst
@@ -0,0 +1,3 @@
+Fix :mod:`sqlite3` CLI completer to include view columns in
+column-name completion.
+
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]