Bug description:
_complete() in Lib/sqlite3/_completer.py restricts column-name
completion to entries in sqlite_master with type='table'. Views
(type='view') are excluded, even though pragma_table_xinfo returns
their columns. The comment above the block already states the intent to
cover views:
# tables, indexes, triggers, and views
Reproducer:
import sqlite3
from sqlite3._completer import _complete
con = sqlite3.connect(":memory:")
con.execute("CREATE TABLE t (a INTEGER, b INTEGER)")
con.execute("CREATE VIEW v AS SELECT a, b, a + b AS sum_ab FROM t")
print(_complete(con, "sum", 0)) # 'SUM('
print(_complete(con, "sum", 1)) # None
con.close()
Expected: _complete(con, "sum", 1) returns 'sum_ab ' (the view column).
Actual: only 'SUM(' is returned.
Fix:
diff
-
WHERE sm.type='table' AND
-
WHERE sm.type IN ('table', 'view') AND
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug description:
_complete()inLib/sqlite3/_completer.pyrestricts column-namecompletion to entries in
sqlite_masterwithtype='table'. Views(
type='view') are excluded, even thoughpragma_table_xinforeturnstheir columns. The comment above the block already states the intent to
cover views:
Reproducer:
Expected: _complete(con, "sum", 1) returns 'sum_ab ' (the view column).
Actual: only 'SUM(' is returned.
Fix:
diff
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs